c# - Copy File in local Network -
this web application have 2 pc's: a: 192.168.1.200 , b: 192.168.1.201, want copy b, code working single pc, it's not working in network.
protected void button1_click(object sender, eventargs e) { string sourcepath = @"d:\source\"; string[] filepaths = directory.getfiles(sourcepath, "*.txt"); foreach (string in filepaths) { copyfiles(a, a.replace("d:\\source\\", "d:\\source1\\new\\")); //copyfiles(a, a.replace("d:\\source\\", "192.168.1.201\\source1\\new\\")); } } private bool copyfiles(string source, string destn) { try { if (file.exists(source) == true) { file.copy(source, destn); return true; } else { response.write("source path . not exist"); return false; } } catch (filenotfoundexception exfile) { response.write("file not found " + exfile.message); return false; } catch (directorynotfoundexception exdir) { response.write("directory not found " + exdir.message); return false; } catch (exception ex) { response.write(ex.message); return false; } }
try with:
copyfiles(a, a.replace("d:\\source\\", "\\192.168.1.201\\source1\\new\\")); you need make sure source1 folder shared on b, , have write access it.
Comments
Post a Comment