Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [System.Web.Services.WebMethod(EnableSession = true)]
- public static void MoveImages(string imageData)
- {
- string fileName = "";
- // get computer name
- string clientMachineName;
- clientMachineName = Dns.GetHostName();
- string computerName = clientMachineName.Split('-').First();
- // get download location
- string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
- string sourcePath = Path.Combine(pathUser, "Downloads");
- string pathstring = @"\servernameshared folder";
- string cls = HttpContext.Current.Session["class"].ToString().Trim();
- string sub = HttpContext.Current.Session["subject"].ToString().Trim();
- string targetPath = System.IO.Path.Combine(pathstring, cls);
- string pathstring1 = targetPath;
- string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
- string destFile = System.IO.Path.Combine(pathstring1, sub);
- if (System.IO.Directory.Exists(sourcePath))
- {
- string[] jpg = System.IO.Directory.GetFiles(sourcePath, "*.jpg");
- string[] png = System.IO.Directory.GetFiles(sourcePath, "*.png");
- string[] files = jpg.Concat(png).ToArray();
- // Copy the files and overwrite destination files if they already exist.
- foreach (string s in files)
- {
- // Use static Path methods to extract only the file name from the path.
- if (s.Length > 0)
- {
- fileName = System.IO.Path.GetFileName(s);
- sourceFile = Path.Combine(sourcePath, fileName);
- destFile = System.IO.Path.Combine(destFile, fileName);
- if (File.Exists(destFile))
- {
- File.Delete(sourceFile);
- }
- else
- {
- File.Copy(sourceFile, destFile);
- }
- }
- }
- }
- <system.web>
- <authentication mode="Windows"/>
- <identity impersonate="true" userName="servrdomainADMINISTRATOR"
- password="pswrd"/>
- <customErrors mode="RemoteOnly" defaultRedirect="someustompage.htm"/>
- </system.web>
Add Comment
Please, Sign In to add comment