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

Using File.Exists

I am trying to see if a file exists in a virtual directory, and if so run a
method. I try doing File.Exists and the method runs but the file isn't there.

Is there a web version of File.Exists or some otherway to get this type of
functionality without too much heartache???

Thanks

--
D @ premierdata
Nov 19 '05 #1
4 2289
You should be able to use File.Exists, but you need to pass it a full
physical path (ie,c:\inetpub\wwwroot\mySite\someFile.txt)

I assume your problem is that you don't have this full physical path. An
easy way to do it is pass the relative or absolute path to Server.MapPath

File.Exists(Server.MapPath("~/myTemp/file.txt"))

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"DE*********@online.nospam" <de*********@online.nospam> wrote in message
news:F1**********************************@microsof t.com...
I am trying to see if a file exists in a virtual directory, and if so run a
method. I try doing File.Exists and the method runs but the file isn't
there.

Is there a web version of File.Exists or some otherway to get this type of
functionality without too much heartache???

Thanks

--
D @ premierdata

Nov 19 '05 #2
Nahh, found a article that talks about authentication issues when trying to
do File.Exists from the web side.

So I am trying a WebClient.Openread(filepath).CanRead.ToString(),

But if the file isn't there I get a 404 error versus a error I textualize to
validate againsts.

Any thoughts on that one?
--
D @ premierdata
"Karl Seguin" wrote:
You should be able to use File.Exists, but you need to pass it a full
physical path (ie,c:\inetpub\wwwroot\mySite\someFile.txt)

I assume your problem is that you don't have this full physical path. An
easy way to do it is pass the relative or absolute path to Server.MapPath

File.Exists(Server.MapPath("~/myTemp/file.txt"))

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"DE*********@online.nospam" <de*********@online.nospam> wrote in message
news:F1**********************************@microsof t.com...
I am trying to see if a file exists in a virtual directory, and if so run a
method. I try doing File.Exists and the method runs but the file isn't
there.

Is there a web version of File.Exists or some otherway to get this type of
functionality without too much heartache???

Thanks

--
D @ premierdata


Nov 19 '05 #3
Humm...no idea.

You might try to turn impersonatation on
(http://www.dotnetspider.com/Technology/KBPages/403.aspx)

just to see if that resolves the authentication issue (will likely cause
other issues, but just to troubleshoot...)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"DE*********@online.nospam" <de*********@online.nospam> wrote in message
news:36**********************************@microsof t.com...
Nahh, found a article that talks about authentication issues when trying
to
do File.Exists from the web side.

So I am trying a WebClient.Openread(filepath).CanRead.ToString(),

But if the file isn't there I get a 404 error versus a error I textualize
to
validate againsts.

Any thoughts on that one?
--
D @ premierdata
"Karl Seguin" wrote:
You should be able to use File.Exists, but you need to pass it a full
physical path (ie,c:\inetpub\wwwroot\mySite\someFile.txt)

I assume your problem is that you don't have this full physical path. An
easy way to do it is pass the relative or absolute path to Server.MapPath

File.Exists(Server.MapPath("~/myTemp/file.txt"))

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"DE*********@online.nospam" <de*********@online.nospam> wrote in message
news:F1**********************************@microsof t.com...
>I am trying to see if a file exists in a virtual directory, and if so
>run a
> method. I try doing File.Exists and the method runs but the file isn't
> there.
>
> Is there a web version of File.Exists or some otherway to get this type
> of
> functionality without too much heartache???
>
> Thanks
>
> --
> D @ premierdata


Nov 19 '05 #4
Hi Dewright,

As you mentioend that you encounter authenticaiton error and 404 error.
I'm a bit confused that whether you're doing the File.Exists check at
clientside app or server side asp.net web app? 404 error is a general
error when the client side request a server doucment on the server which
dosn't acutally exist. And if you're doing this in serverside (in asp.net
app's code), generally the ASP.NET's default process identity should have
the sufficient permission to perform this action. So would you provide some
fruther description on your scenario ?
Looking forward to your response.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net>
| References: <F1**********************************@microsoft.co m>
<uB**************@TK2MSFTNGP14.phx.gbl>
<36**********************************@microsoft.co m>
| Subject: Re: Using File.Exists
| Date: Thu, 7 Jul 2005 17:52:14 -0400
| Lines: 74
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <e9*************@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 206-248-156-127.dsl.teksavvy.com 206.248.156.127
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:111018
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Humm...no idea.
|
| You might try to turn impersonatation on
| (http://www.dotnetspider.com/Technology/KBPages/403.aspx)
|
| just to see if that resolves the authentication issue (will likely cause
| other issues, but just to troubleshoot...)
|
| Karl
|
| --
| MY ASP.Net tutorials
| http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
| http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
| come!)
|
|
| "DE*********@online.nospam" <de*********@online.nospam> wrote in message
| news:36**********************************@microsof t.com...
| > Nahh, found a article that talks about authentication issues when
trying
| > to
| > do File.Exists from the web side.
| >
| > So I am trying a WebClient.Openread(filepath).CanRead.ToString(),
| >
| > But if the file isn't there I get a 404 error versus a error I
textualize
| > to
| > validate againsts.
| >
| > Any thoughts on that one?
| > --
| > D @ premierdata
| >
| >
| > "Karl Seguin" wrote:
| >
| >> You should be able to use File.Exists, but you need to pass it a full
| >> physical path (ie,c:\inetpub\wwwroot\mySite\someFile.txt)
| >>
| >> I assume your problem is that you don't have this full physical path.
An
| >> easy way to do it is pass the relative or absolute path to
Server.MapPath
| >>
| >> File.Exists(Server.MapPath("~/myTemp/file.txt"))
| >>
| >> Karl
| >>
| >> --
| >> MY ASP.Net tutorials
| >> http://www.openmymind.net/ - New and Improved (yes, the popup is
| >> annoying)
| >> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
| >> come!)
| >>
| >>
| >> "DE*********@online.nospam" <de*********@online.nospam> wrote in
message
| >> news:F1**********************************@microsof t.com...
| >> >I am trying to see if a file exists in a virtual directory, and if so
| >> >run a
| >> > method. I try doing File.Exists and the method runs but the file
isn't
| >> > there.
| >> >
| >> > Is there a web version of File.Exists or some otherway to get this
type
| >> > of
| >> > functionality without too much heartache???
| >> >
| >> > Thanks
| >> >
| >> > --
| >> > D @ premierdata
| >>
| >>
| >>
|
|
|

Nov 19 '05 #5

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

Similar topics

2
by: Gary Harvey | last post by:
I have a data intensive program that requires all data to be present in memory. I keep running out of memory at about 2G whenever I run my program. I tried using a 64 bit version of Perl and hit...
1
by: kyma via .NET 247 | last post by:
Hi, I haveto use VB to create a form that reads an exisiting XML fileand then allows updates via the VB form. My problem is that I was able to get VB to read a simple XML file(people.XML), but...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
7
by: andylcx | last post by:
Hi all: The c++ language can check whether the file exist or not. I am wondering how c language does this job? Thanks a lot! Andy
8
by: Darrell Wesley | last post by:
Is there any better method of determining if a file exists then using the Scripting.FileSystemObject If I do thi Dim fs As New System.IO.StreamReader(FileName and the file does not exist...
3
by: moondaddy | last post by:
I need to start an ms access 2003 app from a vb.net winforms app and didn't want to load all the interop stuff for office into the .net project. I thought that using the shell cmd would be a nice...
52
by: paytam | last post by:
Hi all Can anyone tell me how can I check that a file exist or no.I mean when you use this commands FILE *fp; if(!fp) //Could not open the file doen't show why it can not open it,may be the...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
0
by: clinnebur | last post by:
We have an ASP.NET web application (C#) that copies videos from a CCTV truck to a Linux server. What I am trying to do is convert the .AVI videos(which is how they are created on the truck) to .WMV...
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...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.