To write file to other system on LAN
-
We use File.WriteAllBytes("//full path",byteArray) to write file on the drive of the system we are working. But if we want that instead of writing on the same system, it writes on other system on the LAN while we have the privileges to write it then what should be given as parameters in this method or is their any other class that support this?
-
We use File.WriteAllBytes("//full path",byteArray) to write file on the drive of the system we are working. But if we want that instead of writing on the same system, it writes on other system on the LAN while we have the privileges to write it then what should be given as parameters in this method or is their any other class that support this?
Can you map a network drive to that directory and write it that way?
-
Can you map a network drive to that directory and write it that way?
-
Well, you should be able to write to a UNC path, but it would have a lot to do with permissions. Your application may be running under a different identity or a lower trust level than is required. For instance, I can successfully run this code on my network:
static void Main(string[] args) {
FileInfo fi = new FileInfo(@"\\othermachine\C$\IAmATest.txt");
using (StreamWriter sw = new StreamWriter(fi.OpenWrite())) {
sw.WriteLine("Hello World!");
}
fi.Delete();
}There's nothing special required to write to this particular path. I have this inside a command line app and I'm running on a domain account, so I know that I have access to write to that path. If you're running under an NT service or IIS, you may want to impersonate a different user account.