# Trouble delecting UNC file on window 1.8.4

**URL:** <https://www.ruby-forum.com/t/trouble-delecting-unc-file-on-window-1-8-4/71990>\
**Category:** Ruby\
**Created:** [October 13, 2006, 9:35am UTC](https://www.ruby-forum.com/t/trouble-delecting-unc-file-on-window-1-8-4/71990 "2006-10-13T09:35:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgramona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f05b48/32.png) [@cgramona](https://www.ruby-forum.com/u/cgramona)\
**Post date:** [October 13, 2006, 9:35am UTC](https://www.ruby-forum.com/t/trouble-delecting-unc-file-on-window-1-8-4/71990/1 "2006-10-13T09:35:39Z")

</div>

I have a problem delecting a file that has a UNC path. I am using 1.8.4  
on windows and this same thing did work in 1.8.2.

# Here is the pertinent excerpt of code:

puts shp.source; ==\> //rm-graff-c/c$/ftpxfr/somefile2454018103834.txt  
puts LOCDIR + ‘/failed\_files’ ==\>  
//rm-graff-c/c$/ftpxfr//failed\_files  
cp(shp.source, LOCDIR + ‘failed\_files’) ==\> this works  
puts File.file?(shp.source) ==\> this returns true  
rm(shp.source) ==\> this fails with:

# C:/ruby/lib/ruby/1.8/fileutils.rb:1281:in `unlink’: Permission denied - //rm-graff-c/c$/ftpxfr/somefile2454018103834.txt (Errno::EACCES)

I also tried File.delete(…) and several variations. I really doubt  
that the file is open. I do read from earlier in the program using CSV  
but this is in a block and the end of the block (to my knowlege) should  
be automatically closing the file. I could resort to using .new and  
explictily closing the file when CSV reading is done but I more suspect  
that someting has happened between 1.8.2 and 1.8.4 that is the culprit.

Any ideas? Is this a perhaps a known issue that 1.8.5 fixes. I can with  
a little effort try on unix but I am not sure how to form the equivelent  
UNC pathname in unix to //rm-graff-c/c$/ftpxfr/somefile2454018103834.txt

- is the C$ just a windows thing?

Thanks,  
Carl

---

<div class="post-metadata">

**Author:** ![cgramona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f05b48/32.png) [@cgramona](https://www.ruby-forum.com/u/cgramona)\
**Post date:** [October 13, 2006, 6:17pm UTC](https://www.ruby-forum.com/t/trouble-delecting-unc-file-on-window-1-8-4/71990/2 "2006-10-13T18:17:45Z")

</div>

Hi,

At Fri, 13 Oct 2006 16:35:42 +0900,  
Carl G. wrote in [ruby-talk:219487]:

> I have a problem delecting a file that has a UNC path. I am using 1.8.4  
> on windows and this same thing did work in 1.8.2.

I don’t think it is related to UNC.

Probably, just my guess, you are not the owner of that, are  
you?

FileUtils since 1.8.3 changes the permission to 0700, whereas  
0777 before, in order to turn read-only flag off. 0700 means  
it isn’t writable other than the onwer.

> - is the C$ just a windows thing?

No, but it is just an ordinary directory.

---

<div class="post-metadata">

**Author:** ![cgramona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f05b48/32.png) [@cgramona](https://www.ruby-forum.com/u/cgramona)\
**Post date:** [October 13, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/trouble-delecting-unc-file-on-window-1-8-4/71990/3 "2006-10-13T19:04:43Z")

</div>

Nobuyoshi N. wrote:

> Hi,
> 
> At Fri, 13 Oct 2006 16:35:42 +0900,  
> Carl G. wrote in [ruby-talk:219487]:
> 
> > I have a problem delecting a file that has a UNC path. I am using 1.8.4  
> > on windows and this same thing did work in 1.8.2.
> 
> I don’t think it is related to UNC.
> 
> Probably, just my guess, you are not the owner of that, are  
> you?
> 
> FileUtils since 1.8.3 changes the permission to 0700, whereas  
> 0777 before, in order to turn read-only flag off. 0700 means  
> it isn’t writable other than the onwer.
> 
> > - is the C$ just a windows thing?
> 
> No, but it is just an ordinary directory.

Well thanks for both respnses but they “seem” to be somewhat in  
conflict. But you both seem to indicate that I must be the owner of this  
file. I created this file in Ruby using the CSV library while I was  
logged in as a suer whith administrative priviliges.

1. So how do I find out who in owner of this file?
2. The cp command does work which seems to imply that I have write  
priviliges to the subdirectory where I an copying the file to.
3. I even created a new separate share that doesn’t utilize the system  
admin defualt C$ share and gave myself FULL RIGHTS to the folder and  
file - still no luck.

Perhaps I need to explore the FileUtil source code to see if I can find  
out whay this is happening. Is ther a way to change the permission prior  
to trying the delete so that I can delete it?

Thanks for trying to solve this for me,  
Carl

---

<div class="post-metadata">

**Author:** ![cgramona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f05b48/32.png) [@cgramona](https://www.ruby-forum.com/u/cgramona)\
**Post date:** [October 13, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/trouble-delecting-unc-file-on-window-1-8-4/71990/4 "2006-10-13T19:06:02Z")

</div>

Nobuyoshi N. wrote:

> Hi,
> 
> At Fri, 13 Oct 2006 16:35:42 +0900,  
> Carl G. wrote in [ruby-talk:219487]:
> 
> > I have a problem delecting a file that has a UNC path. I am using 1.8.4  
> > on windows and this same thing did work in 1.8.2.
> 
> I don’t think it is related to UNC.
> 
> Probably, just my guess, you are not the owner of that, are  
> you?
> 
> FileUtils since 1.8.3 changes the permission to 0700, whereas  
> 0777 before, in order to turn read-only flag off. 0700 means  
> it isn’t writable other than the onwer.
> 
> > - is the C$ just a windows thing?
> 
> No, but it is just an ordinary directory.

Do you think it is becuase you are going between two different boxes and  
I am trying to do the delete on the same box that the file was created  
and the Ruby program is running?

---

<div class="post-metadata">

**Author:** ![cgramona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f05b48/32.png) [@cgramona](https://www.ruby-forum.com/u/cgramona)\
**Post date:** [October 13, 2006, 7:55pm UTC](https://www.ruby-forum.com/t/trouble-delecting-unc-file-on-window-1-8-4/71990/5 "2006-10-13T19:55:09Z")

</div>

Carl G. wrote:  
Thanks to the bvoth of you for tryin gto resolve this for me. Turns out  
it was a b0ne0head mistake on my part as usual (how embarrasing). I did  
not close teh file after creating it as sheown in the little except that  
follows:

```
reader = CSV.open(locXfrFile, 'r')
top_row = reader.shift # skip top row as it just contains column 

```

names  
reader.each {|r|  
l = ShpLine.new  
ordno = r[3][0,r[3].length-10]  
order[ordno] = ShpOrd.new unless order[ordno]  
attrb\_assign(order[ordno], l, “ship\_date”, r[0])  
…  
detail \<\< l  
}  
reader.close \<= I forgot to put this clcse statement in - duh!

Carl G. wrote:

> Nobuyoshi N. wrote:
> 
> > Hi,
> > 
> > At Fri, 13 Oct 2006 16:35:42 +0900,  
> > Carl G. wrote in [ruby-talk:219487]:
> > 
> > > I have a problem delecting a file that has a UNC path. I am using 1.8.4  
> > > on windows and this same thing did work in 1.8.2.
> > 
> > I don’t think it is related to UNC.
> > 
> > Probably, just my guess, you are not the owner of that, are  
> > you?
> > 
> > FileUtils since 1.8.3 changes the permission to 0700, whereas  
> > 0777 before, in order to turn read-only flag off. 0700 means  
> > it isn’t writable other than the onwer.
> > 
> > > - is the C$ just a windows thing?
> > 
> > No, but it is just an ordinary directory.
> 
> Do you think it is becuase you are going between two different boxes and  
> I am trying to do the delete on the same box that the file was created  
> and the Ruby program is running?

---

<div class="post-metadata">

**Author:** ![cgramona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f05b48/32.png) [@cgramona](https://www.ruby-forum.com/u/cgramona)\
**Post date:** [October 13, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/trouble-delecting-unc-file-on-window-1-8-4/71990/6 "2006-10-13T17:53:40Z")

</div>

On 10/13/06, Carl G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> rm(shp.source) ==\> this fails with:  
> that someting has happened between 1.8.2 and 1.8.4 that is the culprit.
> 
> Any ideas? Is this a perhaps a known issue that 1.8.5 fixes. I can with  
> a little effort try on unix but I am not sure how to form the equivelent  
> UNC pathname in unix to //rm-graff-c/c$/ftpxfr/somefile2454018103834.txt
> 
> - is the C$ just a windows thing?

Are you sure you really have the permissions you need to delete that  
file?  
It’s working fine for me on 1.8.4 between two Windows XP systems.

irb(main):004:0\> file\_path = “[//10.1.2.3/c$/test.txt](https://10.1.2.3/c$/test.txt)”  
=\> “[//10.1.2.3/c$/test.txt](https://10.1.2.3/c$/test.txt)”  
irb(main):005:0\> File.exist?(file\_path)  
=\> true  
irb(main):006:0\> File.delete(file\_path)  
=\> 1  
irb(main):007:0\> File.exist?(file\_path)  
=\> false  
irb(main):008:0\>

I also tried it with escaped backslashes: “\\10.1.2.3.\c$\test.txt”  
…and it worked as well.
