javascript file.Delete Invalid argument

Using javascript, I can save a file or rename it without any problems using Scripting.FileSystemObject activex object.
However, if the user selects to delete one of these same files, I get an "Invalid Argument" error. It uses the exact same path/filename as the save and rename methods.
I can't seem to find any more detail on the error on the object.
Any ideas here ?
function remove_file(fn) {
 var myObject;
  myObject = new ActiveXObject("Scripting.FileSystemObject");
  var f;
  f = myObject.GetFile(this._uploadDirectory + fn); <====causes the error
  f.Delete();
}

Open in new window

MarshallMHSAsked:
Who is Participating?
 
ZvonkoSystems architectCommented:
No problem.
See you.
0
 
Gibu GeorgeChief Technology OfficerCommented:
I thik you need to do like this

f = myObject.GetFile(this._uploadDirectory+"\" + fn);
0
 
MarshallMHSAuthor Commented:
Thanks, but that back-slash is included in the variable this._uploadDirectory.

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Gibu GeorgeChief Technology OfficerCommented:
try an alert (f), post whats the output
0
 
ZvonkoSystems architectCommented:
Add the output of the var conetent to see whether you have slashes in the right place:

  alert(this._uploadDirectory);

0
 
MarshallMHSAuthor Commented:
I can't do the alert on "f" because setting f is what causes the error.
I did inspect the var "this._uploadDirectory" and everything looks fine. It's the same path  used successfully in the save and rename methods that do work.

I did try "if (myObject.FileExists(this._uploadDirectory + fn))" and it returns false even though I can see the file in windows explorer. I am now totally confused  :)

Thanks for the reply !!
0
 
ZvonkoSystems architectCommented:
How is this scipt executed? Is it in a web server page or in a local html file or in a local hta file?
0
 
MarshallMHSAuthor Commented:
The javascript is in a web server page. To be more specific, I use an MS ajax scriptmanager, and load the script file in that.
0
 
ZvonkoSystems architectCommented:
Are you sure you are executing the script on browser client side and the file is located on client disk?
Or are we talking about file shares?
Can we see one example of the variable content?

0
 
MarshallMHSAuthor Commented:
The file(s) are uploaded to the server.
I use a path like: d:\InetPub\application\docs\testfile.txt
I'm thinking that my client side script is looking for a local "D" drive when deleting ???
It does work locally, but not when I publish the site to the server. This is an intranet only site.
0
 
ZvonkoSystems architectCommented:
I wonder that you even succeeded to create the ActiveXObject() on a web server page. That is never going to work. What do you want to delete? If you want to delete the server side files then you need not that JavaScript. You do it in ASP script, right?

 
0
 
ZvonkoSystems architectCommented:
Oh, and if you want to allow a web server page to delet local user files then you can forget it...
0
 
MarshallMHSAuthor Commented:
I am suffering from a mental block today. I use web services regularly and for some reason, today I'm thinking it has to be done with javascript.
My solution is that I use a web service to do the actual deletion.

Thanks for hanging in there with me !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.