I need to upload files dynamically with c# . I can do it with asp.net but O couldn't do it with a desktop app.
I am getting the file to uploaded with open file dialog. Here is my code
string path = "";
OpenFileDialog fDialog = new OpenFileDialog();
fDialog.Title = "Attach PMI document";
fDialog.Filter = "PDF docs|*.pdf|JPG Files|*.jpg|JPEG Files|*.jpeg";
fDialog.InitialDirectory = @"Desktop";
if (fDialog.ShowDialog() == DialogResult.OK)
{
fileName = System.IO.Path.GetFileName(fDialog.FileName);
path = Path.GetDirectoryName(fDialog.FileName);
textBox1.Text = path + "\\" + fileName;
}
no problem with open file dialog.
When i try to save with this code to my computer it was succesful
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsIdentity idnt = new WindowsIdentity(username, password);
WindowsImpersonationContext context = idnt.Impersonate();
File.Copy(@"\\192.100.0.2\temp", @"D:\WorkDir\TempDir\test.txt", true);
context.Undo();
But when i try to copy file to network it gives "error providing a user name is not properly formed account name"
How can i copy that Thanks.