Can someone please guide me how to read/open a pdf file from web site existing on remote file share?
If you can provide with sample code that would be great!
Thanks
Printable View
Can someone please guide me how to read/open a pdf file from web site existing on remote file share?
If you can provide with sample code that would be great!
Thanks
This code is letting me read the properties but does not open the file-
fullFileName is UNC path like
\\servername\path\file.pdf
Any suggestions?Code:Dim fs As New System.IO.FileStream(fullFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
is only working when I run the website locally and access file on remote file share. However, if I publish the website the it gives error-Code:Dim Path = "\\server\myshare\File.pdf"
System.Diagnostics.Process.Start(Path)
The system cannot find the file specified
Any thoughts?
You cannot run the files of a client machine.
Ssingh. The problem is that this codeis running on the server. This is why it works locally as your dev machine IS the server.Code:System.Diagnostics.Process.Start(Path)
Once you have deployed that command is running on the server, not the client you are trying to view it on.
Finally I got the code that works so thought of sharing with the group!
strUNCPath for example "\\server\volume\directory\fileName.pdf"
Thanks for your help!Code:Protected Sub ReadFile(ByVal strOperation As String, ByVal strUNCPath As String)
Select Case strOperation.ToString
Case "Select"
Try
Dim FileName As String = strUNCPath
Dim i As Int32 = 0
impersonateUser.impersonateUser("username", "Doamin", "password")
If strUNCPath.Contains("\") Then
Dim x() = strUNCPath.Split("\")
If Not IsNothing(x) Then
If Not IsNothing(x.GetUpperBound(0)) Then
i = x.GetUpperBound(0)
FileName = x(i).ToString
End If
End If
End If
Dim data As Byte()
data = My.Computer.FileSystem.ReadAllBytes(strUNCPath)
Response.ClearContent()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=" & FileName)
Response.TransmitFile(strUNCPath)
Response.End()
Catch ex As Exception
End Try
Case "Delete"
Try
My.Computer.FileSystem.DeleteFile(strUNCPath)
Catch ex As Exception
End Try
End Select
End Sub
ssingh,
could you please tell me the code for impersonation used in this?
Suhas,
Welcome to the forums!!
Have a look at this thread:
http://www.vbforums.com/showthread.php?t=684652
Hope that helps!
Gary