The below code is an API call in which I'm passing a documentID and I'm trying to open a document. Due to the fact that this whole process is running on a server I'm not able to view the file on any other device(be it another desktop or mobile device) although the file will open up in server machine but wont open locally. Can anyone please guide me through as to where I'm going wrong ? (sorry for the code, I know it might not be perfect as I'm new to web dev. still learning).
{ int i = 1; string key = ConfigurationManager.AppSettings["PhysicalDocumentPath"]; // some address like "xxx.xxx.xxx.xxx\folder\documents...." string key2 = ConfigurationManager.AppSettings["PhysicalDocumentPath2"]; // "C:\{somefolder}\{somefolder}...." JAppDoc value = new JAppDoc(); var response = new Response(); try { if (!Directory.Exists(key2)) { Directory.CreateDirectory(key2); } IAppDataService appDataService = new AppDataService(); response = appDataService.GetDoc(docId, value); var fileName = value.ApplicantId + "_" + value.DocumentName; var savefileName = fileName; var fileSavePath = Path.Combine(key, fileName); var prevPath = fileSavePath; var nextPath = fileSavePath; var tmp = fileName.Split('.'); var tmp1 = tmp[0]; while (File.Exists(nextPath)) { tmp = fileName.Split('.'); fileName = tmp1 + i.ToString(); fileName = fileName + "." + tmp[1]; savefileName = fileName; nextPath = Path.Combine(key, savefileName); if (File.Exists(nextPath)) { prevPath = nextPath; } i++; } try { tmp = prevPath.Split(new[] { "Docs\\" }, StringSplitOptions.None); var serverpath = key + tmp[1]; var localpath = key2+ tmp[1]; if (File.Exists(localpath)) { Process.Start(localpath); } else { System.IO.File.Copy(serverpath, localpath); Process.Start(localpath); } } catch(Exception e) { Utils.Write(e); response.Message = "File not found !"; } } catch (Exception ex) { Utils.Write(ex); } return Ok(response); }
Quote:Well what I have done is just returning back the full path of the file from Api to AngularJS controller and I'm using condition if (response.data.message != null) window.open('//'+response.data.message); else alert("File Not Found !"); in the message part the file path is there. This opens the file in a new tab in the web browser. Thank you everyone for your support . learnt a lot.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)