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

if file exist on the net

i have already a way to know if a file is there by using
System.Net.WebRequest.Create(strURL);

the problem come when checking for huge file. How do i manage that.
because the code define over there read the entire file and output a
string in my case. Is there any other system.net object that could
check only if a file exist.
Feb 8 '08 #1
6 2409
Franck,

Do you mean on a web server (through the HTTP or HTTPS protocol)? If
so, you can issue a HEAD statement and check the response code (it will be
200 if it exists, 404 if not found). Then, if the item exists, you can
issue a GET (or POST, if that is what you are using) to get the actual
content.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Franck" <th***********@hotmail.comwrote in message
news:a1**********************************@i72g2000 hsd.googlegroups.com...
>i have already a way to know if a file is there by using
System.Net.WebRequest.Create(strURL);

the problem come when checking for huge file. How do i manage that.
because the code define over there read the entire file and output a
string in my case. Is there any other system.net object that could
check only if a file exist.
Feb 8 '08 #2
sorry i forgot to explain all. Im using C# windows app and the purpose
is for update application. We already have a webservice on the server
and we use the same server on http port to get the file. i download it
without problem it's just that now i need to add a check if the file
exist.

separate Exe which use System.Net.WebRequest.Create(strURL); on an
xml file on the server that contain the current version. if empty
result mean the user is offline. if it return something i compare the
versions and if higher i update the program.
Feb 8 '08 #3
Franck,

Not to get completely off topic, but since .NET 2.0 (and even before,
with the updater application block in the enterprise library), you haven't
had to do this for yourself because of ClickOnce.

You might want to look into that, as I imagine it will make your life
much, much easier.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Franck" <th***********@hotmail.comwrote in message
news:1a**********************************@i7g2000p rf.googlegroups.com...
sorry i forgot to explain all. Im using C# windows app and the purpose
is for update application. We already have a webservice on the server
and we use the same server on http port to get the file. i download it
without problem it's just that now i need to add a check if the file
exist.

separate Exe which use System.Net.WebRequest.Create(strURL); on an
xml file on the server that contain the current version. if empty
result mean the user is offline. if it return something i compare the
versions and if higher i update the program.

Feb 8 '08 #4
thanks im checking if right now
Feb 8 '08 #5
I tested it and it work on a test project, but our project have too
much dependencies to use that installer. According to the list of
feature i found, the apllication is only install for one user and
inside what's called "clickonce application cache." we actually need
it to be install on multiple user. We aslo have old unmanage dll that
we need to register when first installed. Unless there is special
extra feature somewhere we will keep the basic installer and update im
working on.

So i ask the question again.

Is there a way to know if a file exist using URL ?
Feb 8 '08 #6
Franck,

The method I gave you before will work for HTTP/HTTPS urls, where you
issue a HEAD request to get just the headers. If you get a 200 response,
then you know the item is there. If you get a 404 response, then you know
it doesn't exist.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Franck" <th***********@hotmail.comwrote in message
news:c6**********************************@s37g2000 prg.googlegroups.com...
>I tested it and it work on a test project, but our project have too
much dependencies to use that installer. According to the list of
feature i found, the apllication is only install for one user and
inside what's called "clickonce application cache." we actually need
it to be install on multiple user. We aslo have old unmanage dll that
we need to register when first installed. Unless there is special
extra feature somewhere we will keep the basic installer and update im
working on.

So i ask the question again.

Is there a way to know if a file exist using URL ?

Feb 8 '08 #7

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

Similar topics

10
by: lamar_air | last post by:
I have a python script and i want to delete a file on my computer c:\....\...\.. .txt what's the script to do this? I know how to write to files but i also need to know how to delete a file.
2
by: Chris Fink | last post by:
I am using the System.IO.File class to determine if a file exists on a network share. The File.Exists method keeps returning false, even though the file does exist. The MSDN documentation...
4
by: Mike | last post by:
Hi, I am looking for function in .Net library that let me know if exist any file if I specified template. Eg: I specify "*.txt" and if any file (1.txt, 2.txt, .. ) exists then I can get True...
1
by: Tim Failes | last post by:
This seems a trival question, but I cannot get it to work properly... Essentially my question is, how can I create a text file, and guarantee it is given the current date/time as the Creation Time?...
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...
3
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. ...
26
by: Army1987 | last post by:
Is this a good way to check wheter a file already exists? #include <stdio.h> #include <stdlib.h> int ask(const char *prompt); typedef char filename; int main(int argc, char *argv) { FILE...
7
by: sprash | last post by:
Newbie question: I'm trying to determine if a file physically exists regardless of the permissions on it Using File.Exists() returns false if it physically exists but the process does not...
3
by: brook | last post by:
hey all - i´m new to php and having trouble writing a simple code which should create a file. here is the most simplified version: <?php $content = "my content"; $path = "test.txt";...
65
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.