I need to convert files like pdf and word into links. Is it possible to convert files into attachments? If I click on the link, the file should be downloaded. I tried the below code for getting a link. But it could be opened on our computer only and not opened on another computer because that computer does not have this pdf. Then how to convert the file to a link using c#.
var urlFile = new System.Uri(@"D:\ImagePdf.pdf");
var linkPath = urlFile.AbsoluteUri;
linkPath
output is file:///D:/ImagePdf.pdf
First create a share folder and ensure other computers have access to this folder.
Second specified your computer name/IP address as a setting in your application.
Finally your link could be like this \\{Computer Name\IP address}{Your Share foldername}{Your filename + extension}
You can use System.Diagnostic.Process.Start("filePath") to open the file and you can use System.IO.FIle.Copy() method to "Download" the file. The file must be inside a shared folder to be accessed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.