Karmegam S
Karmegam S

Reputation: 1

How to convert the file into link using c#

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

Upvotes: 0

Views: 598

Answers (2)

S. Stefano
S. Stefano

Reputation: 34

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.

Upvotes: -1

Mahdi Farhani
Mahdi Farhani

Reputation: 1012

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}

Upvotes: 0

Related Questions