473,503 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileInfo Issue

JJ
I have the following code running in a test asp.net app locally on my
xp system and I can't get the FileInfo.Exist to recognize that the file
is in the folder defined in code. What do I need to set in order for
this to work?

string sFullPath = @"\DocTemp\TestDoc.doc";

if(new FileInfo(sFullPath).Exists)
{
sFullPath = sFullPath.Replace(@"\", @"/");

}

JJ

Feb 5 '06 #1
3 2120
Hi JJ,

I suppose DocTemp\TestDoc.doc is in virtual directory. But file system
requires physical directory.

You can try:

string sFullPath = @"\DocTemp\TestDoc.doc";
// or maybe it’s in a relative path
string sFullPath = @"DocTemp\TestDoc.doc";
string physicalPath = Server.MapPath(sFullPath)

if (System.IO.File.Exists(physicalPath))
{
// Process
}
HTH

Elton Wang
"JJ" wrote:
I have the following code running in a test asp.net app locally on my
xp system and I can't get the FileInfo.Exist to recognize that the file
is in the folder defined in code. What do I need to set in order for
this to work?

string sFullPath = @"\DocTemp\TestDoc.doc";

if(new FileInfo(sFullPath).Exists)
{
sFullPath = sFullPath.Replace(@"\", @"/");

}

JJ

Feb 5 '06 #2
It sounds like the web server doesn't know where your page is relative to
the web directory. What does this return?

protected void Page_Load(object sender, EventArgs e)
{
string sFullPath =Server.MapPath(@"DocTemp\TestDoc.doc");

if (new System.IO.FileInfo(sFullPath).Exists)
{
sFullPath = sFullPath.Replace(@"\", @"/");
Response.Write(sFullPath);
}

}
"JJ" <jj****@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I have the following code running in a test asp.net app locally on my
xp system and I can't get the FileInfo.Exist to recognize that the file
is in the folder defined in code. What do I need to set in order for
this to work?

string sFullPath = @"\DocTemp\TestDoc.doc";

if(new FileInfo(sFullPath).Exists)
{
sFullPath = sFullPath.Replace(@"\", @"/");

}

JJ

Feb 5 '06 #3
JJ
great got it to work. Thanks!

JJ

Feb 5 '06 #4

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

Similar topics

1
1585
by: ShikariShambu | last post by:
Hi All, I have a component that is used to do all file access operations. I have this component hosted in COM+ as a server application and runs under a specific id. One of the methods on this...
1
1243
by: Steven J. Reed | last post by:
I'm attempting to determine if a file exists on an Web Server by using FileInfo and specifying an IP address. It works fine if I access another system on my internal network (i.e.,...
0
1450
by: PlanarIndia | last post by:
hi, I am facing an issue with getting the file size of a network shared file. I tried using FileInfo.length and it is returning me size that is rounded off to the nearest 1024 bytes. E.g. for...
2
2499
by: John Bowman | last post by:
Hi All, ..NET 1.1... I'm wondering if there is any approach more convenient to get a list of FileInfo objects than the following. For example, if I wanted to get 1 list of all the Exe's and all...
10
7292
by: Allen | last post by:
When using FileInfo to delete a file, the file remains in the directory (not deleted) Dim foo as New FileInfo(strFileToDelete) Try foo.Delete() Catch ex as IOException 'Open file handler End...
5
6526
by: Lance | last post by:
I want to expose properties of a class to a user via a PropertyGrid class. Some of the properties are of type System.IO.FileInfo. Ideally, an OpenFileDialog window would appear when the user...
3
2155
by: rn5a | last post by:
To work with files, when should one use the File class & when should one use the FileInfo class? Similarly, to work with directories, when should one use the Directory class & when should one...
0
1773
by: comp.lang.php | last post by:
if (!function_exists('mime_content_type_fileinfo')) { /** * Will use {@link http://us2.php.net/fileinfo FileInfo} functions provided within {@link http://pecl.php.net PECL} bundle to return mime...
5
6133
by: Tom P. | last post by:
I am having the following problem: I create a FileSystemWatcher and wait for events. When the event does happen I refresh a FileSystemInfo list and set properties accordingly (IsFile, IsDir,...
0
7199
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
7273
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
7322
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
7451
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
5572
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,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.