List Info

Thread: How to check a file exist on the server..!!




How to check a file exist on the server..!!
country flaguser name
United States
2007-06-17 03:21:04

Dear Friends,

I have 10000 pdf files exist on my sever & I am
maintaining the file names in a database table.

The problem is I have 11000 pdf file names exist on
the database table.
It means that there are 1000 pdf files missing on the
server.
I need to check the files names by picking one by one
from the dabatase table & compare the file name on the
server.
If file exist = false I need to delete the file name
from the database table.
If anyone knows the solution then please let me know
it very urgent.

Thanks & Regards
Parvez Khan

__________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/

__._,_.___
.

__,_._,___
Re: How to check a file exist on the server..!!
country flaguser name
United States
2007-06-17 05:49:53

Ok what you need to do:

select from database like so:
sql = "select id, filename from pdf"
ids = ""

Put that into a datatable .

Loop through it:

for each dtrow as datarow in datatable1.rows
if not system.io.file.exists ("c:mypdffiles" & dtrow("filename"))
ids &= dtrow("id") & ","
end if
next

' chop off last , and make sql
ids = left(myStr,Len(myStr)-1)
sql = "delete pdf where id in (" ids")"

' execute sql

Hope this helps,

Mischa

----- Original Message -----
From: Parvez Khan
To: aspnetanyquestionisok%40yahoogroups.com">aspnetanyquestionisokyahoogroups.com
Sent: Sunday, June 17, 2007 10:21 AM
Subject: [AspNetAnyQuestionIsOk] How to check a file exist on the server..!!

Dear Friends,

I have 10000 pdf files exist on my sever & I am
maintaining the file names in a database table.

The problem is I have 11000 pdf file names exist on
the database table.
It means that there are 1000 pdf files missing on the
server.
I need to check the files names by picking one by one
from the dabatase table & compare the file name on the
server.
If file exist = false I need to delete the file name
from the database table.
If anyone knows the solution then please let me know
it very urgent.

Thanks & Regards
Parvez Khan

__________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )