473,394 Members | 1,794 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,394 software developers and data experts.

Open file on local machine

Hi,
got a datagid which fills files paths in hyperlink controls.
The path of these files looks like "\\MyServer\...\MyFile.xxx"

How can I make my asp.net hyperlink control to open its linked file
with the path as param without opening it in a web page ?

I tried Response.redirect(MyFilePath) but it open the file in the web
page (which I do not want).

Thks for help.

Nov 19 '05 #1
7 8581
What do you mean by "without opening it in a web page "? That, for example,
a .doc file should open in Microsoft Word?

Eliyahu

"Franck" <we**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
got a datagid which fills files paths in hyperlink controls.
The path of these files looks like "\\MyServer\...\MyFile.xxx"

How can I make my asp.net hyperlink control to open its linked file
with the path as param without opening it in a web page ?

I tried Response.redirect(MyFilePath) but it open the file in the web
page (which I do not want).

Thks for help.

Nov 19 '05 #2
Yep (if possible... regarding security)... asking user what to do,
open, cancel, save, etc...

Nov 19 '05 #3
Create a page that'll stream the .doc file to the user.

(It should by default then ask the user weather they want to Open or Save it
Opening it, should open it in word.)

The code will look something like this:

using System.IO;

Response.ClearContent();
Response.ContentType = "application/msword";
Response.WriteFile(MyFilePath ); //this will be like /file/fileiwant.doc
Response.End();

"Franck" <we**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
got a datagid which fills files paths in hyperlink controls.
The path of these files looks like "\\MyServer\...\MyFile.xxx"

How can I make my asp.net hyperlink control to open its linked file
with the path as param without opening it in a web page ?

I tried Response.redirect(MyFilePath) but it open the file in the web
page (which I do not want).

Thks for help.

Nov 19 '05 #4
The point that the user could insert in the database whatever file he
wants...

If he inserts a path to a file from which the extension is a strange
one... it's over.

Starting to think I'll forbide every files except Office ones and Pdf...

Nov 19 '05 #5
Try this:

HOWTO: Raise a "File Download" Dialog Box for a Known MIME Type
http://support.microsoft.com/default...;en-us;q260519

Eliyahu

"Franck" <we**********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Yep (if possible... regarding security)... asking user what to do,
open, cancel, save, etc...

Nov 19 '05 #6
I'll look after that, thks ^^

Nov 19 '05 #7
You can also code the page to determine what file type it is by viewing the
extension and setting the ContentType appropriately.

I normall break down the filename to get the extension, then run a swtich on
that extension to set the content type:
If it wasn't one i was prepared for, i'll throw an exception, or write an
error message to the screen

switch (strFileExtension)
{
case ".pdf":
sContentType = "application/pdf";
break;
case ".ppt":
sContentType = "application/x-mspowerpoint";
break;
case ".tif":
sContentType = "image/tiff";
break;
case ".bmp":
sContentType = "image/bmp";
break;
case ".gif":
sContentType = "image/gif";
break;
case ".zip":
sContentType = "application/x-zip-compressed";
break;
case ".xls":
sContentType = "application/vnd.ms-excel";
break;
}

sdf

"Franck" <we**********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
The point that the user could insert in the database whatever file he
wants...

If he inserts a path to a file from which the extension is a strange
one... it's over.

Starting to think I'll forbide every files except Office ones and Pdf...

Nov 19 '05 #8

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

Similar topics

12
by: Matt | last post by:
I want to write a ASP page to open/download a file In fileview.jsp, I have the file browse, and when user click submit button, fileview2.asp should open the file. fileview.asp ============...
3
by: WM Chung | last post by:
Hello all, My dotnet application configuration is that the client, Web server and database all reside in 3 different computers. There is a function which can browse a file and read in the...
4
by: Brad | last post by:
Error when opening a solution with a web services project in it: "Unable to open the Web project 'myproj'. The file path 'c:\code\myservice' does not correspond to the URL...
4
by: Yuri Vorontsov | last post by:
Hallo! We have troubles (post XP SP2) to open local folders from the web application: - the web application allows users to select a local file (input type=file) - the system DOES NOT upload...
29
by: Tola | last post by:
In my case of study, my teacher gave me a project, after I analysed the problem I found that I had to used open the file on the other machine? Please help? Thank you in advance. Tola CHROUK
8
by: Lam | last post by:
HI anyone knows how can I open a mapped network file in C#? I try string file = @"T:\file.txt"; it shows me the error: "Could not find a part of the path" but if I copy the file to my C dirve,...
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
1
by: max.aginaga | last post by:
Hi everyone I've come across the following problem: on two different linux machines, both running python 2.5 (r25:51908), I have the same file 'd.dat'. The md5 checksums are the same. Now, on...
5
by: =?Utf-8?B?QWRyaWFuTW9ycmlz?= | last post by:
Hello! I'm trying to copy a file from another computer on the network that I do not have permission with my current logon details to access. If I open the folder using the Windows file manager...
2
by: saketmayur | last post by:
Hi , I have write the following code to open word document on server using Microsoft.Office.Interop.Word; string DocPath = System.Configuration.ConfigurationManager.AppSettings; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.