/    Sign up×
Community /Pin to ProfileBookmark

Javascript help on deleting the file

Hi All,

I need to delete a file which resides in the path “c:inetpubwwwrootpic”. I am using the FSO and using the path as “picfile1.gif” to delete the file. Eventhough the “file1.gif” is present in the localhost path the script gives “File not found” error when it executes the file.Delete() method of FSO.

It works fine if I give full path as below.

file = myfso.GetFile(“c:inetpubwwwrootpicfile1.gif”)
file.Delete()

But my requirement is to delete the file without using the c:inetpubwwwrootpicfile1.gif”

Thanks in advance.

Ravi

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mwiggin1Aug 24.2005 — Is this JavaScript or ASP? Looks like ASP ...

If it is ASP just use:

FilePath = Server.MapPath("/pic/file1.gif")

objFile = myfso.GetFile(FilePath)

objFile.Delete()

This thread should be moved to ASP ...
Copy linkTweet thisAlerts:
@u_ravi10authorAug 25.2005 — I am creating an instance of the filescripting object and using its methods to get the file and delete it inside a javascript function. So I am trying do everything in a javascript function only.

Following is the code used:

I am passing the value "picfile1.gif" to fpath argument used for the function filsel.

<SCRIPT LANGUAGE="JavaScript">

function filsel(fpath) {

myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");

// The below commented code works fine //

//file = myActiveXObject.GetFile("c:inetpubwwwrootpicfile1.gif");

file = myActiveXObject.GetFile(fpath);

file.Delete();

}

</SCRIPT>



Thanks.

Ravi
×

Success!

Help @u_ravi10 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...