473,698 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to delete this file ???

DCK
Hello

I've path to file, which look like this:
\\COMPUTER\D$\C ++\FILE_TO_DELE TE.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.fileexi sts() 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 2972
DCK wrote:
Hello

I've path to file, which look like this:
\\COMPUTER\D$\C ++\FILE_TO_DELE TE.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.fileexi sts() 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_DELE TE.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.fileexi sts() 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.linu x.org> wrote in
news:ma******** *************** **************@ python.org:
DCK wrote:
I've path to file, which look like this:
\\COMPUTER\D$\C ++\FILE_TO_DELE TE.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.fileexi sts()
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.u k
int month(char *p){return(1248 64/((p[0]+p[1]-p[2]&0x1f)+1)%12 )["\5\x8\3"
"\6\7\xb\1\x9\x a\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\an y\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\an y\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.normpat h() 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
14152
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 delete these files. I am using following code: // get list of all files in the directories
0
2098
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. Once the compare is complete the file that was copied to a temp location needs to be deleted. I am using the method file.copy(sourcePath, tempPath, true) to copy the file and then file.delete(tempPath) to delete the file. On some of the files...
5
5243
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 discussions of new and delete is a pretty damn involved process but I'll try to stick to the main information I'm looking for currently. I've searched around for about the last too weeks and have read up on new and overloading it to some extent but...
23
8940
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 the remove function that is included with <cstdio> but cannot get it to work properly. My reference book has the following....
12
8001
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 File.Delete(Filename) Next Catch ex As Exception
9
8334
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) and two folders (Subfolder 1, Subfolder 2). .......I need to delete File1, File2, File3. Subfolder 1 contains FileA. .......Need to delete FileA. Subfolder 2 contains FileB, FileC, FileD.
2
4748
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 file sharing. And have specified the "Allow network users to change my files." option as well. Then on my laptop (xp home sp2) I have mapped a network drive using windows explorer. So on my laptop I have a Y: drive that points to the "Visual...
5
39030
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 Explorer. I can delete all of them through Windows Explorer. I can programmatically delete the text file but not the others. Permissions: - All files have the same ACL.
3
3279
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 (i.e. the root directory). This is the code: <script runat="server"> Sub MoveFile(ByVal obj As Object, ByVal ea As EventArgs) File.Move(fudFileSource.FileName, txtFileDest.Text) 'File.Move("F:\4.jpg", "C:\4.jpg") End Sub
7
4221
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) File.Delete(L3Global.VideoFileName) ' The following is not working - reports directory not empty exception ' Directory.Delete(fDir)
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.