473,508 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding the file availability

440 Contributor
Hi ,

I would like to know whether the file is available at that particular location or not.
I/P:
Say 'C:\Sample\Sample.txt'

O/P:

If the file is available : Yes
If the file is not available : No


Thanks
PSB
May 15 '07 #1
4 1114
Motoma
3,237 Recognized Expert Specialist
I am sure you could do with with stat(), but there are probably other ways of doing it as well. Opening it for reading will probably work too, if you interpret the result of the open call correctly.

Hi ,

I would like to know whether the file is available at that particular location or not.
I/P:
Say 'C:\Sample\Sample.txt'

O/P:

If the file is available : Yes
If the file is not available : No


Thanks
PSB
May 15 '07 #2
psbasha
440 Contributor
I am sure you could do with with stat(), but there are probably other ways of doing it as well. Opening it for reading will probably work too, if you interpret the result of the open call correctly.
Could you please a snippet of the code
May 15 '07 #3
bvdet
2,851 Recognized Expert Moderator Specialist
Expand|Select|Wrap|Line Numbers
  1. >>> import os
  2. >>> p = r'C:\SDS2_7.0\macro\Zip\tem.txt'
  3. >>> os.path.isfile(p)
  4. True
  5. >>> p = r'C:\SDS2_7.0\macro\Zip\tem.zip'
  6. >>> os.path.isfile(p)
  7. False
  8. >>> 
May 15 '07 #4
ghostdog74
511 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. >>> filepath=os.path.join("/tmp","file")
  2. >>> if os.path.exists(filepath):
  3. ...   print "Found: " , filepath
  4. ...   if os.path.isfile(filepath):
  5. ...       print "%s is a file " % filepath
  6. ... 
  7.  
pls spend some time reading the docs on os, sys modules.
May 16 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1842
by: Joan MacEachern | last post by:
Date: Thursday, October 2, 2003 Time: 10-11am PT/ 1-2pm ET Some business applications define mission critical. You just can't afford to have them go down. Ever. Is 'always on' a realistic...
2
1852
by: DonMiche | last post by:
I'm having trouble producing an xml output from another xml file using xsl. The proper values are output to the browser as text with no formating or xml tags (<rowset> and <row>). Any ideas? ...
7
1887
by: Shane | last post by:
Hi, Thanks in advance for the help. I have been to many websites and tried several solutions to my problem, but have fixed part of it. It's time to come humbly to the newsgroups for help :-) ...
4
1790
by: John Coen | last post by:
Help, does anyone have a database I could use to record downtime on multiple systems, that will also show me availability percentages on a day to day basis worked against actual service hours. If...
4
1723
by: Jeremy | last post by:
How can I prove uptime (or quantify downtime) on an ASP.NET 1.1 Web application (running on an IIS6 Windows Server Standard server)? What's going on here is that I'm considering the feasability...
12
3366
by: e271828 | last post by:
Hi, I'm helping to work a developer tool that verifies a given HTML element has a given attribute (e.g., that all LABEL elements have a FOR attribute, all INPUT elements have an ID attribute,...
0
1862
by: NSF12345 | last post by:
Iv developed a small program that looks for a file over our network, and copy it to the location of another computer. Im using the "If FileExists("\\oldpc\main share\Folder\file.txt") Then" way of...
8
1253
by: TDB | last post by:
int main() { void *p; p=(void *)0x00000005; // Here printf(" %d ",* (int *)p); return 0; }
6
2961
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hello, I have an XML file generated from a third party application that I would like to parse. Ideally, I plan on having a windows service setup to scan various folders for XML files and parse the...
0
7336
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
7401
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...
1
7063
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
5640
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,...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3211
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
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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 ...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.