Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a program to copy file form one Pc to other Pc ,i tried with File.Copy and In Textbox3 i am providing IpAddress with Path ex:@"10.29.80.123\\newFolder" program is not giving Exceptions and errors but giving Expected output.


Please help to resolve.

What I have tried:

C#
private void btn_ChooseFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();
            openFile.ShowDialog();
            textBox1.Text = openFile.FileName;
            filename = textBox1.Text;
        }
 private void btn_Copy_Click(object sender, EventArgs e)
        {
            copy();
}
 public void copy()
        {
            string sourceFileName;
            string backup;
            try
            {
                
                sourceFileName = Path.GetFileName(filename);
                File.Copy(Path.Combine(filename, sourceFileName), Path.Combine(textBox3.Text, sourceFileName),true);
            }
            catch
            {
                MessageBox.Show("File Not Found");
            }
        }
Posted
Updated 8-Aug-16 0:42am
v2

1 solution

Try add \\ to the start of your path e.g \\10.29.80.123\newFolder or as a c# string :
C#
string path = "\\\\10.29.80.123\\newFolder";
 
Share this answer
 
Comments
Member 12528561 8-Aug-16 7:09am    
I added \\ still its not giving expected output,it throwing exception that
Could not find a part of the path 'C:\\Users\\Desktop\\, this path i am giving for file to copy.
Mehdi Gholam 8-Aug-16 7:14am    
Make sure your source and destination paths are valid and you can manually copy from and to them first.
Jorge M Ramirez 10-Aug-16 19:42pm    
You first need to share the folder, else the OS won't allow you to access it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900