473,325 Members | 2,828 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,325 software developers and data experts.

How to delete this file ???

DCK
Hello

I've path to file, which look like this:
\\COMPUTER\D$\C++\FILE_TO_DELETE.JPG
This path was generated by os.path.walk() function. When i try to delete
this file, os.remove() can't find it, os.path.fileexists() can't find it :(
I can delete other files (i.e. \\COMPUTER\D$\C\FILE_TO_DELETE.JPG). I guess
there's a problem with this C++ directory (++ exacly). I tried to change it
to C\+\+, but this still not work. I've no idea how to delete this file.

I work under WinNT 4.0 with sp6, python 2.3 with unicode support. I have
adminstrator rights.
Can somebody help me ?
--
/===============---------
/ Wygenerowal: DCK
/ dnia: 2003-12-01 10:49:25
/===========---------
Jul 18 '05 #1
5 2951
DCK wrote:
Hello

I've path to file, which look like this:
\\COMPUTER\D$\C++\FILE_TO_DELETE.JPG
This path was generated by os.path.walk() function. When i try to delete
this file, os.remove() can't find it, os.path.fileexists() can't find it :(
I can delete other files (i.e. \\COMPUTER\D$\C\FILE_TO_DELETE.JPG). I guess
there's a problem with this C++ directory (++ exacly). I tried to change it
to C\+\+, but this still not work. I've no idea how to delete this file.

I work under WinNT 4.0 with sp6, python 2.3 with unicode support. I have
adminstrator rights.
Can somebody help me ?


Are you sure you have quoted your back-slashes correctly? It works for me:

python -c "import os;print os.path.exists(r'\\eden\e\temp\delme')"
True

Mark.

Jul 18 '05 #2
DCK wrote:
I've path to file, which look like this:
\\COMPUTER\D$\C++\FILE_TO_DELETE.JPG
What do you mean exactly by: 'looks like'? Is it the full path to the
file? How did you find out?
This path was generated by os.path.walk() function. When i try to delete
this file, os.remove() can't find it, os.path.fileexists() can't find it :(
Does the directory exist, e.g., what does
'os.path.exists('\\computer\d$\c++') give as result? And
'os.path.exists('\\computer\d$')? I think a 'd$' is usually a share in
Windows (not sure), maybe you haven't turned the share on (I'm not sure
what 'mounting' is called in Windows)?
I can delete other files (i.e. \\COMPUTER\D$\C\FILE_TO_DELETE.JPG). I guess
there's a problem with this C++ directory (++ exacly). I tried to change it
to C\+\+, but this still not work. I've no idea how to delete this file.

I work under WinNT 4.0 with sp6, python 2.3 with unicode support. I have
adminstrator rights.
Can somebody help me ?


Maybe. Can you give some more precise information? What is your
os.path.walk command? How does it reach this path?

yours,
Gerrit.

--
169. If he be guilty of a grave fault, which should rightfully deprive
him of the filial relationship, the father shall forgive him the first
time; but if he be guilty of a grave fault a second time the father may
deprive his son of all filial relation.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/

Jul 18 '05 #3
Gerrit Holl <ge****@nl.linux.org> wrote in
news:ma*************************************@pytho n.org:
DCK wrote:
I've path to file, which look like this:
\\COMPUTER\D$\C++\FILE_TO_DELETE.JPG


What do you mean exactly by: 'looks like'? Is it the full path to the
file? How did you find out?
This path was generated by os.path.walk() function. When i try to
delete this file, os.remove() can't find it, os.path.fileexists()
can't find it :(


Does the directory exist, e.g., what does
'os.path.exists('\\computer\d$\c++') give as result? And
'os.path.exists('\\computer\d$')? I think a 'd$' is usually a share in
Windows (not sure), maybe you haven't turned the share on (I'm not
sure what 'mounting' is called in Windows)?


You need some raw string quoting there.

os.path.exists(r'\\computer\d$\c++') would check for the existence of a
directory c++ on drive D of the computer named 'computer', provided you
have administrative access to the remote computer. The drive letter shares
c$ (and d$ etc. where there is more than one drive) are created
automatically and are only accessible to administrators. The UNC pathnames
being used mean that there is no need to mount the drive before accessing
it.

os.path.exists(r'\\computer\d$') will return False whether or not the share
exists, however os.path.exists(r'\\computer\d$\\') will return True if the
share exists. Note that you need two trailing backslashes even if you don't
use the raw quoting.

I tried creating a file called FILE_TO_DELETE.JPG in a directory called C++
on a remote machine. I checked the existence of both the file and directory
using os.path.exists, and then removed first the file and then the
directory using os.remove. Both operations worked as expected, so the '+'
character in the filename is not a problem (Python 2.3). I suspect the OP
must have something else wrong, possibly a confusion over backslashes, or
possibly just insufficient access to the C++ directory (just because you
have access to the admin shares doesn't mean you necessarily have full
access to all the directories).

--
Duncan Booth du****@rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
Jul 18 '05 #4
DCK
Hello again
Really sorry for long time between me letters. All problem gone, after i've
used raw string (r"\\path\to\any\file") Really thanks for all answers :)

Thank's again !
Jul 18 '05 #5
DCK wrote:

Hello again
Really sorry for long time between me letters. All problem gone, after i've
used raw string (r"\\path\to\any\file") Really thanks for all answers :)


Note that it's almost always better to use forward slashes instead.

In this case, "//path/to/any/file" would work wonderfully, and is much
more readable.

Yes, it does work with Windows. The only time it doesn't is when using
command line programs which interpret the forward slash as an option,
and insist on backslashes.

(An unfortunate additional area is that os.path for Windows normalizes
things to use backslashes, and therefore path comparisons can get a little
tricky if you use forward slashes but aren't careful about normalizing
with os.path.normpath() all the time.)

-Peter
Jul 18 '05 #6

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

Similar topics

5
by: Jobs | last post by:
Hello All, I want to delete all files in a directory. I am making a backup copy of all files in the directories say c:\abc by reading and writing to a file. After making a backup copy I want to...
0
by: SeanR | last post by:
I have a function to copare two files. It will first copy the original file form a different server to a local temp path and then compare that version to a version that has been restored form tape....
5
by: | last post by:
Hi all, I've been using C++ for quite a while now and I've come to the point where I need to overload new and delete inorder to track memory and probably some profiling stuff too. I know that...
23
by: da Vinci | last post by:
Greetings, Onwards with the school studying. Working on a program and need to delete a file from a known location on the hard drive but cannot get anything I do to work. I have tried to use...
12
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
2
by: createdbyx | last post by:
I am trying to make a file sync utillity to sync files between my laptop and my desktop pc. On my desktop machine (xp pro sp2) I have shared my "Visual Studio Projects" folder using windows simple...
5
by: wo20051223 | last post by:
Deleting some files with C# fails with "Access to the path 'X' is denied". I have files copied from a CD that I burned (and not locked by a process) and a text file that I created in Windows...
3
by: Arpan | last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls. Using the FileUpload control, I want to give users the provision to move & delete files that DO NOT exist in C:\Inetpub\wwwroot...
7
by: Anil Gupte | last post by:
Private Sub mnu2Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu2Exit.Click Dim fDir As String = Path.GetDirectoryName(L3Global.VideoFileName) ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.