Home > Software engineering >  How to convert the file into link using c#
How to convert the file into link using c#

Time:09-09

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

CodePudding user response:

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}

CodePudding user response:

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.

  • Related