Hi, I won't tell you that you shouldn't do this or that your question is all wrong. I'll just try to give you an answer you can use. There are a few nice built-in .NET methods for copying a file. Here are two: IO.File.Copy(sourceFileName,destFileName) My.Computer.FileSystem.CopyFile(sourceFileName,destinationFileName) They both do the same thing, though I prefer the first example. The second example is not available if you are programming in C#, so it helps with portability not to use it. Others have already warned you about the problems with hard-coding these paths and with possible/probable security problems in copying to your system directory Now, with regards to your second question (running 392.exe) without knowing the path, the short answer is, "No", it is not possible. The long answer is, "Yes", it is possible, but it is clunky. There are two strategies that I can think of. The first strategy involves environment variables, and someone else already talked about that. I wouldn't recommend that approach for a bunch of reasons. The second approach involves searching for the file, then running it. The problems with this are: - It is potentially quite slow. It could take a long time to find the file. - It is potentially dangerous. If there was another file named "392.exe" that you didn't want to run, the code might find it and run it anyway. However, the code for finding the file and running it would look something like this:
Private Function FindFile(ByVal fileName As String, ByVal searchDirectory As String) As String
Dim fullPath As String = ""
If Not IO.Directory.Exists(searchDirectory) Then Throw New IO.DirectoryNotFoundException
fullPath = IO.Path.Combine(searchDirectory, fileName)
If Not IO.File.Exists(fullPath) Then
fullPath = ""
Try
For Each subDirectory As String In IO.Directory.GetDirectories(searchDirectory)
fullPath = FindFile(fileName, subDirectory)
If fullPath <> "" Then Exit For
Next
Catch uaException As UnauthorizedAccessException
fullPath = ""
End Try
End If
Return fullPath
End Function
This function will search all subdirectories to which your app has access for the file in question. You would use it like this:
myFile = FindFile("392.exe", "C:\")
If IO.File.Exists(myFile) Then Process.Start(myFile)
This woul