I have a text box and a button in a form.i want to save a file into the network path entered in the textbox while clicking the button. i tried the code given below.
private void button1_Click(object sender, EventArgs e)
{
string destinationPath = txtFilePath.Text.ToString();
string sourceFile = @"c:\1.txt";
string fileName = Path.GetFileName(sourceFile);
System.IO.File.Copy(sourceFile, Path.Combine(destinationPath, fileName));
}
it works fine if the destination provided the permission to change content. If the destination is 'read only' then it gives the error. if the input is \192.168.0.24\aqm , then it shows the error shown below (the path do not have write permission)
Access to the path '\192.168.0.24\aqm\1.txt' is denied.
is there anyway to solve this. i mean, if the destination is read only, then it prompt username and password of that system , if username password entered correct, then save the file to that directory . the user knows the username and password of all the computers in the network. cant give write permission to every system casue of some security reason. thats why i am looking for a method i suggested above
or any other ways?? Hope someone help me