?
Solved

javascript file.Delete Invalid argument

Posted on 2009-05-06
13
Medium Priority
?
327 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:MarshallMHS
  • 6
  • 5
  • 2
13 Comments
 
LVL 12

Expert Comment

by:Gibu George
ID: 24316976
I thik you need to do like this

f = myObject.GetFile(this._uploadDirectory+"\" + fn);
0
 

Author Comment

by:MarshallMHS
ID: 24316995
Thanks, but that back-slash is included in the variable this._uploadDirectory.

0
 
LVL 12

Assisted Solution

by:Gibu George
Gibu George earned 400 total points
ID: 24317236
try an alert (f), post whats the output
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 63

Expert Comment

by:Zvonko
ID: 24317532
Add the output of the var conetent to see whether you have slashes in the right place:

  alert(this._uploadDirectory);

0
 

Author Comment

by:MarshallMHS
ID: 24317644
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 24317707
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
 

Author Comment

by:MarshallMHS
ID: 24317763
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 24317804
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
 

Author Comment

by:MarshallMHS
ID: 24317969
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 24318024
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 24318117
Oh, and if you want to allow a web server page to delet local user files then you can forget it...
0
 

Author Comment

by:MarshallMHS
ID: 24318121
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
 
LVL 63

Accepted Solution

by:
Zvonko earned 1600 total points
ID: 24318140
No problem.
See you.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question