zrubi zrubi - 1 year ago 129
C# Question

Directory path for executable

Hello I’m trying create directory file with text document inside my first windows form application executable, but something is wrong here:

I want make it available with exe file for other local user computers:

string dir = @"C:\Users\Public\AppData\Roaming\AppFolder\document.txt";
if (!Directory.Exists(dir))
var stream = File.CreateText(dir);

but I got this:

An unhandled exception of type 'System.IO.IOException' occurred in

Additional information: The process cannot access the file
because it is being used by another process.

Answer Source

I guess you need to issue the commands for the stream to be accessible anywhere else

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download