Guest User

Untitled

a guest
Aug 2nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. [System.Web.Services.WebMethod(EnableSession = true)]
  2. public static void MoveImages(string imageData)
  3. {
  4. string fileName = "";
  5. // get computer name
  6.  
  7. string clientMachineName;
  8. clientMachineName = Dns.GetHostName();
  9. string computerName = clientMachineName.Split('-').First();
  10.  
  11. // get download location
  12.  
  13. string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
  14. string sourcePath = Path.Combine(pathUser, "Downloads");
  15.  
  16.  
  17. string pathstring = @"\servernameshared folder";
  18.  
  19.  
  20.  
  21. string cls = HttpContext.Current.Session["class"].ToString().Trim();
  22. string sub = HttpContext.Current.Session["subject"].ToString().Trim();
  23. string targetPath = System.IO.Path.Combine(pathstring, cls);
  24. string pathstring1 = targetPath;
  25. string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
  26. string destFile = System.IO.Path.Combine(pathstring1, sub);
  27.  
  28.  
  29. if (System.IO.Directory.Exists(sourcePath))
  30. {
  31.  
  32. string[] jpg = System.IO.Directory.GetFiles(sourcePath, "*.jpg");
  33. string[] png = System.IO.Directory.GetFiles(sourcePath, "*.png");
  34. string[] files = jpg.Concat(png).ToArray();
  35.  
  36. // Copy the files and overwrite destination files if they already exist.
  37. foreach (string s in files)
  38. {
  39. // Use static Path methods to extract only the file name from the path.
  40. if (s.Length > 0)
  41. {
  42. fileName = System.IO.Path.GetFileName(s);
  43. sourceFile = Path.Combine(sourcePath, fileName);
  44.  
  45. destFile = System.IO.Path.Combine(destFile, fileName);
  46. if (File.Exists(destFile))
  47. {
  48. File.Delete(sourceFile);
  49.  
  50. }
  51. else
  52. {
  53.  
  54.  
  55. File.Copy(sourceFile, destFile);
  56.  
  57. }
  58. }
  59. }
  60. }
  61.  
  62. <system.web>
  63.  
  64. <authentication mode="Windows"/>
  65. <identity impersonate="true" userName="servrdomainADMINISTRATOR"
  66. password="pswrd"/>
  67. <customErrors mode="RemoteOnly" defaultRedirect="someustompage.htm"/>
  68. </system.web>
Add Comment
Please, Sign In to add comment