|
From: Jim Gregg on 8 Jul 2008 11:02 Hello all, Can someone help me out with an error I am getting? When I try to save a file with no extension, I recieve a bad file name or number error. here is the code that throws the error: Set objFile = objFSO.CreateTextFile(strPath, True) objFile.Write(strList) objFile.Close The problem is that strPath is "C:\Program Files\Some App\FILE" where FILE is actually the file name. I assume that I am getting this error because vbscript thinks FILE is a directory. Is there anyway to save a text file with no extension? By the way, this is the 2nd time I tried to post this so I apologize if my post shows up twice for some reason. I waited 2 hours but my old post never showed up. JG
From: ekkehard.horner on 8 Jul 2008 11:19 mayayana schrieb: >> If there is a directory "C:\Program Files\Some App\FILE", an attempt >> to .CreateTextFile( "C:\Program Files\Some App\FILE", True ) will fail >> with a "permission denied" error. > > That's a different issue and would typically only > apply to Vista. > > I used code like this: On Error Resume Next WScript.Echo 0, CreateObject( "WScript.Shell" ) _ .RegRead( "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProductName" ) If 0 <> Err.Number Then WScript.Echo 1, CreateObject( "WScript.Shell" ) _ .RegRead( "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion" ) End If On Error GoTo 0 Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" ) Dim sName For Each sName In Array( "noextension", "same.as" ) If oFS.FolderExists( sName ) Then oFS.DeleteFolder sName If oFS.FileExists( sName ) Then oFS.DeleteFile sName oFS.CreateTextFile( sName, True ).Write "Was wollt Ihre denn, es geht doch!" WScript.Echo 2, oFS.OpenTextFile( sName ).ReadAll oFS.DeleteFile sName oFS.CreateFolder sName On Error Resume Next oFS.CreateTextFile( sName, True ).Write "Was wollt Ihre denn, es geht doch!" WScript.Echo 3, Err.Number, Err.Description On Error GoTo 0 Next to verify that creating a text file with the same name as an existing directory fails under W2K and XP.
From: Old Pedant on 8 Jul 2008 21:11 "mayayana" wrote: > > > > > If there is a directory "C:\Program Files\Some App\FILE", an attempt > > to .CreateTextFile( "C:\Program Files\Some App\FILE", True ) will fail > > with a "permission denied" error. > > That's a different issue and would typically only > apply to Vista. Pardon me, but that's nonsense. It applies to virtually any operating system ever created that supports directories, at all. You can't create a file within a given directory that has the same name as a subdirectory of that same given directory. Was true in MS-DOS version 1 and in various operating systems before that. Is true in Linux, Unix, and who knows what other operating systems.
From: mayayana on 8 Jul 2008 23:10 > > That's a different issue and would typically only > > apply to Vista. > > Pardon me, but that's nonsense. Yes. I misread the post, thinking that he was referring to permission issues in Program Files.
|
Pages: 1 Prev: Number exponentiation Next: Load Web form with Excel row (code example) |