FSO - Sort


Here is my code and it works. But as you can see it sors the files according to the name. I want to sort it for the date.

Code: 0 then fileCount = filecount + 1 redim preserve fNames(fileCount) redim preserve fDates(fileCount) fDates(fileCount) = objFile.DateLastModified fNames(fileCount) = lcase(objFile.name) end if next for tName = 1 to filecount for nName = (tName + 1) to filecount if (fDates(tName) < fNames(nName)) then 'Sort dates buffer = fDates(nName) fDates(nName) = fDates(tName) fDates(tName) = buffer 'Sort names buffer = fNames(nName) fNames(nName) = fNames(tName) fNames(tName) = buffer end if next next set objFolder = nothing set objFSO = nothing %> ................... Nome File PDF
Data Creazione
...................... How can i do it\t

Posted On: Friday 26th of October 2012 07:36:26 AM Total Views:  579
View Complete with Replies

RELATED TOPICS OF ASP PROGRAMMING LANGUAGE




fso.Getfolder - 2 Pages, exact code, one works - one does not???

Please look at these two bits of code This one returns "path not found" Code: and this one works Code: Why, both files are in the same darn directory.
VIEWS ON THIS POST

334

Posted on:

Saturday 18th August 2012
View Replies!

create txt files without fso??

hi, is there a way to create and handel with text files without using fso I used this: DIM fso, TextFile Set fso = CreateObject("Scripting.FileSystemObject") Set TextFile = fso.CreateTextFile("y:\ttmtext.txt", True) Function click1() TextFile.WriteLine ("!!Blablabla!!") End Function which works fine, but unfortunatly doesn't fit into the security policy...... is there another way to do this\t tnx
VIEWS ON THIS POST

215

Posted on:

Sunday 19th August 2012
View Replies!

fso.fileExists Function Not Working Correctly

The following code always displays 'false' in the browser window, which indicates that it's not finding the file. The file definitely exists - any idea why it doesn't work
VIEWS ON THIS POST

169

Posted on:

Sunday 26th August 2012
View Replies!

Problem with fso movefile (file already exists)

Guys I'm posting files using a multipart form and ms posting acceptor to a folder on our intranet server. No problem. I then attach them to an email using CDONTS and off they go. Now, I was then deleting them from the folder using fso deletefile and all was fine but I decided that rather than delete them, I would move them to another folder. I create the subfolder thus: Code: 'create a folder especially for this requisition... Dim filesys, demofolder, folcoll Set filesys = CreateObject("Scripting.FileSystemObject") Set demofolder = filesys.GetFolder("D:\intranet\uploads\") Set folcoll = demofolder.SubFolders folcoll.Add(rs.Fields("requisitionID").Value) ...fine, but then when I try to move the files: Code: '...and move the attachments into it.... dim objfilesys for intx = lbound(arrX) to ubound(arrX) Set objfilesys = CreateObject("Scripting.FileSystemObject") objfilesys.MoveFile Server.MapPath("../uploads/" & arrX(intx)), Server.MapPath("../uploads/" & rs.Fields("requisitionID").Value & "/") Next it all goes pear shaped and I get the error: Microsoft VBScript runtime error '800a003a' File already exists Any help would be greatly appreciated as I'm just about fed up of all this web development lark and am contemplating becoming a zoo keeper instead. Or something. Cheers
VIEWS ON THIS POST

284

Posted on:

Tuesday 28th August 2012
View Replies!

possible fso problem

I have an asp script meant to take the first record from my database and write it to a csv file on the server. The code meant to do this is: Code: SQL = "SELECT TOP 1 * FROM UserRequest ORDER BY RecordID DESC" Set aRS = Conn.Execute (SQL) dim filesavepath Dim F, Head 'This is where you want to Write the CSV File. This example is a physical path. filesavepath = "e:\prod\intranet\www-gs\pdh\insertData.csv" set FSO = Server.CreateObject("scripting.FileSystemObject") set csvfile = fso.CreateTextFile(filesavepath, true) 'This loops through the database and then writes into CSV format. 'Head is the Field names. 'Body are the actual records For Each F In aRS.Fields Head = Head & ", " & F.Name Next Head = Mid(Head,3) & vbCrLf Body = aRS.GetString(,,", ",vbCrLf,"") csvfile.WriteLine(Head) csvfile.WriteLine(Body) csvfile.Close I do make the connection object earlier in the code, and it works. (That is, it does the stuff to the database that preceedes this code.) When I run the whole page, there are no errors, and everything else works correctly, but the csv file is not generated, which is the point of this code. Are there any problems with my code here, or might the permissions be set wrong on the server
VIEWS ON THIS POST

246

Posted on:

Tuesday 28th August 2012
View Replies!

VBScript - General - Error - Space in filename, fso.GetFile error

Here's the very simple code: Set fso = CreateObject("Scripting.FileSystemObject") strFile = "\\server\share$\Adobe_ShockWave\Adobe Shockwave 1150600.msi" Set f = fso.GetFile(strFile) strExt= UCase(fso.GetExtensionName(f)) response.write strExt When I run this as ASP from the web server, I get File Not Found. When I run it as VBscript locally, it works. The only change is replacing "response.write" with "wscript.echo" I've tried: strfile = """" & strfile & """"" strfile = chr(34) & strfile & chr(34) But neither is working. What do I have to do to get it to handle filenames with spaces
VIEWS ON THIS POST

353

Posted on:

Tuesday 28th August 2012
View Replies!

VBScript - General - Error - Permission Denied on fso.CopyFile

Hi everybody, I'm having tremendous difficulty determining the source of a problem. I've been running the same script for a couple of years now, and suddenly it no longer works. It uses the CopyFile method to copy an mdb file. Today it decided to start returning a "permission denied" error, although I haven't changed the code. In my troubleshooting efforts, I have discovered that I can still use DeleteFile and CreateTextFile methods, as all permissions are set for the IUSR user for 100% control. Only the CopyFile method is returning the error. I have also discovered that it denies permission for the same method on a simple text object, so it has nothing to do with the file type. I've also made sure no files in question are set to "read only". As I mentioned before, this script was working just fine for a couple of years until I tried to use it tonight (although it could have happened anytime in the last 30 days or so, since I last ran the script). Other pertinent info: I'm running asp 3 on a Windows Server 2003 SP1. Somebody please help! It's driving me crazy and the well-being of my website depends on it!
VIEWS ON THIS POST

208

Posted on:

Tuesday 28th August 2012
View Replies!

VBScript - General - Error - Permission Denied on fso.CopyFile

Hi everybody, I'm having tremendous difficulty determining the source of a problem. I've been running the same script for a couple of years now, and suddenly it no longer works. It uses the CopyFile method to copy an mdb file. Today it decided to start returning a "permission denied" error, although I haven't changed the code. In my troubleshooting efforts, I have discovered that I can still use DeleteFile and CreateTextFile methods, as all permissions are set for the IUSR user for 100% control. Only the CopyFile method is returning the error. I have also discovered that it denies permission for the same method on a simple text object, so it has nothing to do with the file type. I've also made sure no files in question are set to "read only". As I mentioned before, this script was working just fine for a couple of years until I tried to use it tonight (although it could have happened anytime in the last 30 days or so, since I last ran the script). Other pertinent info: I'm running asp 3 on a Windows Server 2003 SP1. Somebody please help! It's driving me crazy and the well-being of my website depends on it!
VIEWS ON THIS POST

197

Posted on:

Tuesday 28th August 2012
View Replies!

Asp fso read first 13 caracters of variable to?

ihi i have a txt file and need to read the first 13 caracters out of it into a asp variable i have the file read out to asp variable called new sip so do newsip= objHTTP.ResponseText Dim ObjCounterFile, ReadCounterFile, WriteCounterFile Dim CounterFile Dim CounterHits Set ObjCounterFile = Server.CreateObject("Scripting.FileSystemObject") CounterFile = Server.MapPath ("test.txt") Set ReadCounterFile= ObjCounterFile.OpenTextFile (CounterFile, 1, True) If Not ReadCounterFile.AtEndOfStream Then CounterHits = Trim(ReadCounterFile.ReadLine) If CounterHits = "" Then CounterHits = newsip Else CounterHits = newsip End If ReadCounterFile.Close Set ReadCounterFile = Nothing CounterHits = newsip Set WriteCounterFile= ObjCounterFile.CreateTextFile (CounterFile, True) WriteCounterFile.Write(CounterHits) WriteCounterFile.Close Set WriteCounterFile = Nothing Set ObjCounterFile = Nothing i need to copy out the first 13 caracters only any ideas
VIEWS ON THIS POST

190

Posted on:

Tuesday 28th August 2012
View Replies!

ASP equivelant of fsockopen()

Is there something similiar to the fsockopen() function from PHP, in ASP I need to connect to whois servers on port 43, but I don't know of any functions/components in ASP which allow me to do this.
VIEWS ON THIS POST

248

Posted on:

Thursday 13th September 2012
View Replies!

fso.FileExists question

I have a web page that pulls a list of reports that are stored on a NAS TeraStation.Essentially, it queries the database for the customer and project and pulls a list of report numbers, then does a fso.fileexists in ASP, and if it finds the file, puts a link on the screen that when clicked, streams the file to the user's browser.Overall it works great.Unless the person has a LOT of reports.\tSince there are several thousand reports on the NAS, and if a customer has a lot (2 or 3 dozen) reports, it can take up to 2 or 3 minutes to build the list.Is there a faster way than looping the fso.FileExists to see if the file actually exists on a network driveI thought about building a table that lists all of the files, except that some of this can happen "real time", so doing a once-a-day file list isn't really helpful.Perhaps there's an ASP routine that caches all the filenames in a folder that I could then scrub through\tOr perhaps a single read to load the filelist into an array (so it's only one call to the NAS)What do you folks think\tAny help is appreciated. Just my 2"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."--Greg\thttp://parallel.tzo.com
VIEWS ON THIS POST

350

Posted on:

Tuesday 25th September 2012
View Replies!

fso.size gives wrong size?

Hi all, I'm using this code to try and get the size of a file (.zip file in this case). Code: Function getFileSize(theFile) Dim fso, f, s Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(Server.MapPath(theFile)) Then Set fso = fso.GetFile(Server.MapPath(theFile)) s = fso.size & " Bytes." Else s = "Error getting file size" End If response.write(s) set fso = nothing End Function I do not need to know anything about the folder it's in, or any other files in that folder (in this particular script). Also, I had to use the mappath routine, otherwise I couldn't get the fso to return. The code functions properly, but it doesn't return the size of the file as seen with an explorer window. If I look at the file's properties, the size that's returned with this code is the size in (parenthesis). I need to return the size that's displayed in an explorer window. How can I do that
VIEWS ON THIS POST

352

Posted on:

Wednesday 10th October 2012
View Replies!

Regular Expressions in fso.DeleteFile

Can I use regexps in fso.DeleteFile I've found I can use a '' and probably a '*' (although that seems a tad brutal) but I'm having trouble with expressions like ([a-z]|[0-9]-). Am I wasting my time trying to get it to work (i.e. does it support them) If so, how do I use them Does it have its own quirky syntax or "standard" regexp Every example I've found so far just mentions deleting something simple like *.txt. For the record, I need to "tidy up" a directory full of images by deleting files whose names _don't_ contain particular text. It's quite convoluted and would be far easier if I could just go through each file one by one but hey. Here are the details: 1) I have a list of IDs in an array that I've read from a data source. This is the "current ID" list 2) I have a list of image filenames from a directory in another array. The image filenames contain an ID in them. There could be none, one or more images containing the same ID. 3) I look at each file in turn, extract the ID portion and add it to an array of "found" IDs - crucially, this array is only updated if the ID has not been seen before in another filename 4) I then step through this array and use Filter() to see if the ID is in the "current ID" list somewhere 5) If it is missing from the list, that ID is deemed "out of date" and all associated images containing that ID need to be deleted. Message to screen saying that ID has been deleted. 6) If it is in the list, just print a message saying it is "current" and move on. I realise I could just step through each file and test it against the current ID list but then the output on-screen would be file-by-file and not ID-by-ID. The client doesn't care how many files there are; they don't even care about the underlying structure - they just point the browser to my script and it deletes the files, shows them which IDs have been removed and tells them how many IDs in total have been deleted. If I went down that route I would have to keep a record of which IDs I've deleted and output the lot at the end instead of 1 by 1 as I go, which leaves the browser hanging for a while and doesn't give the client reassuring feedback as it ploughs through the directory adding the results to the screen row by row. The annoyance is that the filenames and directories are a mess. The image filenames are (currently) one of these formats: {letter}{branch}_{ID}.jpg or {number}-{branch}_{ID}.jpg (The {number} can be anything from 1 to 100). So once I find an ID that's missing I want to just pass a generic "regular expression" to fso.DeleteFile and have it delete all matching images. I'm reluctant to pass: Code: filesToDelete = "*" & branch & "_" & ID & ".jpg" to DeleteFile because there are all manner of other files in the same directory, including my script itself and other scripts/control files (yes, it's a horrible mess but I'm working on someone else's server and have no control over what's placed where). If something went wrong it could blat a lot of important stuff. I would feel safer with something like: Code: filesToDelete = "([a-z]|[0-9]+-)" & branch & "_" & ID & ".jpg" But that doesn't work: fso.DeleteFile matches nothing. Anyone any insight into how I can achieve this Many
VIEWS ON THIS POST

196

Posted on:

Wednesday 10th October 2012
View Replies!

Using fso to get list of files but can't use mapped network drive

I run this code below to list the contents of a directory on the webserver. It works fine with all directory's except mapped network drives. Any idea why it won't work and how I can get it to work
VIEWS ON THIS POST

268

Posted on:

Thursday 11th October 2012
View Replies!

problems with fso and IIS 5.1 on win xp pro, please help?

Originally posted by : ouaknine mickael (vaknin22@netvision.net.il)the fso doesn't work. what I need to doplease hel
VIEWS ON THIS POST

423

Posted on:

Thursday 11th October 2012
View Replies!

XML fso.DeleteFile problem

Originally posted by : Rob (rweiss@tri-global.com)the following code will create the file fine but if the file already exists, it will find it but the fso.DeleteFile line will cause the page to hang up. \t\t\tWhy\t\t\tSet rst = Server.CreateObject("ADODB.Recordset")set fso = createobject("scripting.filesystemobject")strFile= "xmlfiles/" & Session.SessionID & ".xml"If fso.FileExists (Server.MapPath(strFile)) then fso.DeleteFile Server.MapPath(strFile)End Ifrst.Open mSQL,dbConn,3,3rst.Save Server.MapPath(strFile), adPersistXMLSet fso = Nothing
VIEWS ON THIS POST

458

Posted on:

Thursday 11th October 2012
View Replies!

fso gallery type loop

, I have a folder full of images and i just want to display the file names in that folder. My current code just writes down a list of file which is what i want, but the problem is that it is just a very long list. What i want to do is to output the file like gallery type output say 4 columns across then next row. I am not sure with the syntax can somebody please tell me how i can go about this below is my current code
VIEWS ON THIS POST

289

Posted on:

Thursday 11th October 2012
View Replies!

fso loop problem

I am not sure where I am going wrong, I have written a script that opens, reads a text file then adds the contents to a text file in another folder. The problem I am having is the first folder has several text files and I want to loop through each text file and copy the contents of each one to the new folder but to one text file. e.g folder 1 has 6 text files and I want the contents of each file only copied to folder2 to a single text file. I also need file 5 to be ignored, as this file does not need to be added.This works but only moves the first folder as I have declared the folder to look but the problem is it does not loop through the files and it does not ignore file 5.Option ExplicitDim objFSO, objFolder, objShell, objTextFile, objFile, sReadDim strDirectory, strFile, strText,strDirectory2, strFile2, files, filestrDirectory = "c:\fso\test"strDirectory2 = "c:\fso2\test2"strFile = "\fso.txt"strFile2 = "\fso.txt"'strText = "this should come from the txt file"' Create the File System ObjectSet objFSO = CreateObject("Scripting.FileSystemObject")' Check that the strDirectory folder existsIf objFSO.FolderExists(strDirectory) Then\tSet objFolder = objFSO.GetFolder(strDirectory)Else\t\tWScript.Echo " The File" & strDirectory & "does not exist"End Ifset objFile = nothingset objFolder = nothingConst ForAppending = 8, ForReading = 1, ForWriting = 2set files = objFSO.GetFolder("c:\fso\test").Filesfor each file in filesSet objTextFile = objFSO.OpenTextFile _(strDirectory & strFile, 1, True)' Writes strText every time you run this VBScriptsRead = objTextFile.ReadobjTextFile.CloseSet objTextFile = objFSO.OpenTextFile _(strDirectory2 & strFile2, 2, True)' Writes strText every time you run this VBScriptobjTextFile.WriteLine(sRead)nextobjTextFile.CloseWScript.QuitCan anyone help
VIEWS ON THIS POST

318

Posted on:

Monday 15th October 2012
View Replies!

fso.GetFileVersion size limit?

Got a bit of a weird problem.We are using standard fso.GetFileVersion code in order to get the version number of the latest dll used to create some documents.We normally loop through the files to get the latest version (and this works fine on all the DLL's). However in the example below I am hard-coding the file name. The error occurs either way.'**********************************strName = "Docs_9_12_3_0.dll"\t\t\t\t\t\t\tSet fso = CreateObject("Scripting.FileSystemObject")\t\t\tversion_no = fso.GetFileVersion("c:\Inetpub\wwwroot\location\DLLs\" & strName & "")\t\t\tResponse.Write version_no'*********************************The code works perfectly on any file under 1.8 MB, however as soon as the file is over that size I am unable to get the version information.This problem only occurs on our live server, on our test server the same code (pointing at the same files) works perfectly.The two servers are using the same version on windows with all the same service packs.I have checjed the IIS settings and they seem identical, although I am not really sure what I am looking for.Does anyone has any suggestions on how to resolve this
VIEWS ON THIS POST

316

Posted on:

Monday 15th October 2012
View Replies!

Access denied - fso.Createtextfile

Please help! Error: (0x800A0046) Access denied. I have (Windows XP and Office XP and) this file: C:/Inetpub/wwwroot/ExcelApp/index.asp I try to create a text file like this (in javascript): var fso = new ActiveXObject("Scripting.FileSystemObject"); var textFile = fso.Createtextfile("textFile.txt",true); // This line errors! I have tried this one two other computers and there in works! I have checked and double-checked the permissions over and over again. IUSR_XXX has all the rights there is in wwwroot and ExcelApp. If I do like this it works: var textFile = fso.Createtextfile("C:/Inetpub/wwwroot/ExcelApp/textFile.txt",true); Because this works (I can also create folders) I dont think i has to do with permissions. Am I wrong I also try to create an Excel file like this: var fso2 = new ActiveXObject("Scripting.FileSystemObject"); var excelFile = new ActiveXObject("Excel.Application"); // This line errors! ...and get the same error. This also works on other computers.
VIEWS ON THIS POST

364

Posted on:

Friday 26th October 2012
View Replies!