2011-10-10 51 views
1

我不知道如何在ASP中打开文件。这是我的代码不工作。如何在ASP中打开文件

<% 
    Dim vid_file 
    vid_file = Request.ServerVariables("APPL_PHYSICAL_PATH")& "cannon\pay\vid.dat" 
    Dim vkey_file 
    vkey_file = Request.ServerVariables("APPL_PHYSICAL_PATH")& "cannon\pay\vkey.dat" 

    dim fp1,f 
    set fp1 = Server.CreateObject("Scripting.FileSystemObject") 
    set f=fp1.OpenTextFile(Server.MapPath("vid_file"),8,true) 
    f.WriteLine("This text will be added to the end of file") 
    f.Close 

    set f=Nothing 
    set fp1=Nothing 

    'Single Variable Declarations 
    dim fp2,f2 
    set fp2 = Server.CreateObject("Scripting.FileSystemObject") 

    'fExists=FileSysObj.FileExists(vid_file) 
    set f2=fp2.OpenTextFile(Server.MapPath("vkey_file"),8,true) 
    'set TextStreamObj = fp2.OpenTextFile(vkey_file,1,true) 
    'TextStreamObj.WriteLine("This text will be added to the end of file") 
    f2.WriteLine("This text will be added to the end of file") 
    f2.Close 

    set f2=Nothing 
    set fp2=Nothing 
%> 
+0

** **如何在它不工作?有没有错误信息? –

+0

@Cheran S :)你能不能查看这个天气我错了还是对吗? http://pastebin.com/5Wqd6kk2 – php

回答

1
<% 
    Dim vid_file 
    vid_file = Request.ServerVariables("APPL_PHYSICAL_PATH")& "cannon\pay\vid.dat" 
    Dim vkey_file 
    vkey_file = Request.ServerVariables("APPL_PHYSICAL_PATH")& "cannon\pay\vkey.dat" 

    dim fp1,f 
    set fp1 = Server.CreateObject("Scripting.FileSystemObject") 
    set f=fp1.OpenTextFile(vid_file,8,true) 
    f.WriteLine("This text will be added to the end of file") 
    f.Close 
    set f=Nothing 
    set fp1=Nothing 
    'Single Variable Declarations 
    dim fp2,f2 
    set fp2 = Server.CreateObject("Scripting.FileSystemObject") 
    'fExists=FileSysObj.FileExists(vid_file) 
    set f2=fp2.OpenTextFile(vkey_file,8,true) 
    'set TextStreamObj = fp2.OpenTextFile(vkey_file,1,true) 
    'TextStreamObj.WriteLine("This text will be added to the end of file") 
    f2.WriteLine("This text will be added to the end of file") 
    f2.Close 
    set f2=Nothing 
    set fp2=Nothing 
    %> 
+0

:)是不是现在?http://pastebin.com/HUv8t7KE – php

+0

你只需要将这个代码Server.MapPath(“vkey_file”)替换为vkey_file,就是这样...它会完美地工作。 –

+0

这是为你工作吗? –