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
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.
Slow as hell.
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
Last edited by ssingh; May 23rd, 2012 at 08:50 AM.
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
Remember to mark your thread as resolved. Remember to rate posts that help. Hitchhiker's Guide to Getting Help at VB Forums.
ASP.NET Tutorials (updated Feb 1st 2009) ASP.NET FAQs (updated July 17th 2011)
Free Stuff: WebsiteSpark|DreamSpark|BizSpark|eBooks
Learning Resources: MSDN|LearnVisualStudio|TrainingSpot|ScottGu's Blog|ASP.Net Starter Kits|Regex|RegExLib
Useful Tools: XPath Builder|UltraMon|RegExBuddy|CopySourceAsHtml|TracExplorer|SQLyog|Chart Controls for .Net|SharePoint Designer|CodeRush Express
Coding Links: XPath|ConnectionStrings|VB and MySQL|MySQL Connector.Net|My.Settings
ADO.Net: MSDN Reference|Introduction|Using Access|Always use Parameters|Save and Retrieve Data - jm|An Explanation - jm
Code Bank Submissions: Code Snippets|Profile Provider|Serialization: C# VB|Restricted Menu|Compressed HttpWebRequest|Enumerate and Add Internet Explorer Favourites: VB C#|C# Tabbed Web Browser|Enhanced Tabbed Web Browser: VB C#
My Blog - View my MCP Certifications