user3850146
user3850146

Reputation: 97

Where Does My.Computer.Filesystem Point?

I assumed (and we all know what that gets you) that My.Computer.Filesystem pointed to where the exe was installed. Most of the time, that premise is holding true. However, occasionally it is pointing to C:\Windows\System32 and my code is failing due to permissions.

So where is it really pointing and why the difference?

Thanks

Upvotes: 0

Views: 437

Answers (1)

Visual Vincent
Visual Vincent

Reputation: 18320

Instead of using a relative path use Path.Combine() together with Application.StartupPath. The latter will get the directory where the .exe was started from.

My.Computer.FileSystem.WriteAllText(Path.Combine(Application.StartupPath, "done.txt"), "0", False, Encoding.ASCII)

Upvotes: 2

Related Questions