Ask the Expert

Using ASP.NET and C#, how ,can I make a file copy to a local drive and open up when a user selects i

I am trying to use C# and ASP.NET to make some internal programs for our firm. In one phase, I checked the existence of a file on one of our network drives, which I also mapped to a drive on the server. If a user selects that file, I want it to copy to the local drive on the server and then have it open up for the user (files are MS Word documents).

I used System.IO.File.Exist method to check the file. It works for the local drive, but it doesn't work for the network drive (i.e. N:docshowto.doc). System.IO.File.Copyto also doesn't work for the network drive. It gives me this error message: "Could not find file "N:docshowto.doc."

How can I do this in ASP.NET and C#?
First, you're missing the slashes. You must use "N:\\docshowto.doc" or @"@"N:\docshowto."

Second, you should use UNC paths: @"\\myserver\share\docshowto.doc."

What's more, the network path may be better placed in the application web.config.

This was first published in February 2003

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: