473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Open File

Dear Experts,

I'm trying to open a file from my web form. However, when I click on the
button, no action is being performed. I have tried running it in debugging
mode, the file is able to open. Below is the partial of my code:
-------------------------------------------------------------------------------------------
<td colspan="1" style="height: 20px">
<asp:Label ID="lblAttachment" runat="server"
Text="Attachment:" Visible="False"></asp:Label></td>
<td colspan="5" style="height: 20px">
<asp:TextBox ID="txtAttachment" runat="server"
BorderStyle="None" ReadOnly="True" Visible="False"
Width="250px"></asp:TextBox>
<asp:Button ID="btnViewAttachment" runat="server"
Text="View" Visible="False" OnClick="ViewDoc" /></td>

---------------------------------------------------------------------------------------------
Public Sub ViewDoc(ByVal Source As Object, ByVal E As EventArgs)
Dim strFilename As String
'Dim blnOpenDoc As Boolean
strFilename = Trim(txtAttachment.Text)
Try
Dim Proc As New System.Diagnostics.Process
Proc.StartInfo.WorkingDirectory =
"C:\Data\Websites\Intranet\TeknionLocal\FrontPage2 000\Teknion\ITRS\App_Data\Attachments"
Proc.StartInfo.FileName = strFilename
Proc.Start()
'OpenDocument(strFilename)
'Return True
Catch ex As Exception

End Try
End Sub
----------------------------------------------------------------------------------------------

Please advise on what is the mistake I have done or I have not done to put
into the code. The document that I tried to open is Word and Excel.
Many thanks in advance.

Regards,
SB
Feb 1 '06 #1
1 1458
Hi there Seok,

I'm not sure if you are aware what you're doing now :) You're opening a file
(creating a process) on the server not on the client, so it works only if you
browse this page from the same machine as web server. If you want to
attach/embed excel/word document to a page (you have already created related
post) use MIME attachements with Response.ContentType.

Hope this helps
--
Milosz Skalecki
MCP, MCAD
"Seok Bee" wrote:
Dear Experts,

I'm trying to open a file from my web form. However, when I click on the
button, no action is being performed. I have tried running it in debugging
mode, the file is able to open. Below is the partial of my code:
-------------------------------------------------------------------------------------------
<td colspan="1" style="height: 20px">
<asp:Label ID="lblAttachment" runat="server"
Text="Attachment:" Visible="False"></asp:Label></td>
<td colspan="5" style="height: 20px">
<asp:TextBox ID="txtAttachment" runat="server"
BorderStyle="None" ReadOnly="True" Visible="False"
Width="250px"></asp:TextBox>
<asp:Button ID="btnViewAttachment" runat="server"
Text="View" Visible="False" OnClick="ViewDoc" /></td>

---------------------------------------------------------------------------------------------
Public Sub ViewDoc(ByVal Source As Object, ByVal E As EventArgs)
Dim strFilename As String
'Dim blnOpenDoc As Boolean
strFilename = Trim(txtAttachment.Text)
Try
Dim Proc As New System.Diagnostics.Process
Proc.StartInfo.WorkingDirectory =
"C:\Data\Websites\Intranet\TeknionLocal\FrontPage2 000\Teknion\ITRS\App_Data\Attachments"
Proc.StartInfo.FileName = strFilename
Proc.Start()
'OpenDocument(strFilename)
'Return True
Catch ex As Exception

End Try
End Sub
----------------------------------------------------------------------------------------------

Please advise on what is the mistake I have done or I have not done to put
into the code. The document that I tried to open is Word and Excel.
Many thanks in advance.

Regards,
SB

Feb 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yanivmad | last post by:
hi I like to ask if there any option to control the html files?!? I have some HTML files at my web site that use one "Help.htm" file for all the pages {I use the "window.open(.... " option at...
9
by: Charles F McDevitt | last post by:
I'm trying to upgrade some old code that used old iostreams. At one place in the code, I have a path/filename in a wchar_t string (unicode utf-16). I need to open an ifstream to that file. ...
6
by: Dino Buljubasic | last post by:
My application creates some temporary files that are deleted when my application terminates. However, if a temp file is open, it will not be deleted and application will crash. How can I...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
6
by: qysbc | last post by:
I have a web page and there is a link to open a TIFF file. The way I do it is to have the server code open a binary stream, set the content type to "image/tiff" and call Response.BinaryWrite. On...
2
by: OutdoorGuy | last post by:
Greetings, I have a "newbie" question in relation to opening files from C#. I have a Windows form where I allow the user to type in a file extension in a text box (e.g., "xls"). I then take...
6
by: Moumen VB.NET 2003/2005 Developer | last post by:
How can I detect if a file sitting on a network drive is still open by another application? This application resides on another machine on the network? I am using VB.NET 2003 Your help is...
5
by: Ryan Liu | last post by:
Hi, Both way works, I'd just ask some experts which way is better? My application creates a log file daily. Now each time when I write a log, I will open the file and append to the end....
6
by: Ros | last post by:
There are 10 files in the folder. I wish to process all the files one by one. But if the files are open or some processing is going on them then I do not want to disturb that process. In that case...
0
by: Ofelia | last post by:
Hi, I'm new to this forum and to Perl language but I would like to ask for your help. I'm working in Linux and the files I need to process are in the format “file.gz”. I created a script which...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.