Remove a file over the network on a Sun

H

Hans Stoessel

Hi

I have a C application on a Windows PC who shoul delete files on a Sun which
is in the same network. I try this with the 'remove' command, e.g.
remove(\\Sun\Temp\File.jpg). But this doesn't work. The return code from
remove is not 0 and the errno is 22 (invalid argument).

What could be wrong?

I have access to the Sun and have tried this with the directory mounted or
not mounted and I have tried the same (delete a file) on a Windows and a Mac
OS X machine in the netwroks. This works fine.

Thanks for any help.

Regards
Hans
 
J

Joona I Palaste

Hans Stoessel said:
I have a C application on a Windows PC who shoul delete files on a Sun which
is in the same network. I try this with the 'remove' command, e.g.
remove(\\Sun\Temp\File.jpg). But this doesn't work. The return code from
remove is not 0 and the errno is 22 (invalid argument).
What could be wrong?

Assuming that the above was just a typo and the correct function call
was remove("\\\\Sun\\Temp\\File.jpg"), the answer is that it depends
entirely on your operating system and is not related to C at all.
I have access to the Sun and have tried this with the directory mounted or
not mounted and I have tried the same (delete a file) on a Windows and a Mac
OS X machine in the netwroks. This works fine.

This is irrelevant as far as C is concerned.
 
G

Guest

Hans said:
I have a C application on a Windows PC who shoul delete files on a Sun which
is in the same network. I try this with the 'remove' command, e.g.
remove(\\Sun\Temp\File.jpg).

remove("\\\\Sun\\Temp\\File.jpg");

- Dario
 
D

Dan Pop

In said:
I have a C application on a Windows PC who shoul delete files on a Sun which
is in the same network. I try this with the 'remove' command, e.g.
remove(\\Sun\Temp\File.jpg). But this doesn't work. The return code from
remove is not 0 and the errno is 22 (invalid argument).

What could be wrong?

Your remove call is certainly wrong. Try one of the following:

remove("\\\\Sun\\Temp\\File.jpg");
remove("//Sun/Temp/File.jpg");

and be sure that your capitalisation is correct.

Dan
 
R

Ralmin

Hans Stoessel said:
I have a C application on a Windows PC who shoul delete files on
a Sun which is in the same network. I try this with the 'remove'
command, e.g. remove(\\Sun\Temp\File.jpg). But this doesn't work.
The return code from remove is not 0 and the errno is 22 (invalid
argument).

What could be wrong?

Maybe you didn't write the string correctly (correct capitalisation?), or
maybe your `remove' function does not support UNC paths (very unlikely for a
program run on Windows).

Try:
result = remove("\\\\Sun\\Temp\\File.jpg");

Yes, all those backslashes are required. The reason is that in a C string or
character literal, the backslash introduces an escape sequence (hexadecimal,
octal or control character). A double backslash is interpreted as a single
real backslash.

It works on Cygwin GCC. It works on Borland C++. It works on LCC-Win32. It
works on the Microsoft compiler. It even works on the 1998 DOS compiler
Turbo C 2.01!
 
H

Hans Stoessel

Hi

Sorry, that was my fault: In fact I use the double backslash of course. I
use remove as remove(sPath.c_str()).

But whats about UNC paths? Whats that? By the way: I can create, write and
read the file but I can't remove it. Maybe something with the permission?
The problem is that the SUN is not located in my company...

Thanks for the help
Hans
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top