448,505 Members | 1,200 Online
Need help? Post your question and get tips & solutions from a community of 448,505 IT Pros & Developers. It's quick & easy.

# How to delete this file ???

 P: n/a 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 Replies

 P: n/a 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

 P: n/a 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  P: n/a Gerrit Holl 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

 P: n/a 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

 P: n/a 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 discussion thread is closed

Replies have been disabled for this discussion.