2009-06-17 9 views
0

저는 3 ~ 4 년 전에 회사에서 만든 누군가에게 .hta를 수정하려고합니다. 지금 다른 사람이 이미 열어 놓은 파일을 열면 지금까지 해 온 작업을 잃어 버리고 수동으로 다시해야합니다. 그래서 파일이 이미 열려 있는지 확인한 다음 편집을 잠그는 것만 보거나 그냥 "이봐, 네가 저장하려고하면 실망 할거야"라고 말하는 팝업을 만드는 것만으로 생각했습니다. 파일이 이미 자바 스크립트에서 열려 있는지 확인하는 쉬운 방법이 있습니까?파일이 이미 javascript/hta에 열려 있는지 감지합니다.

파일을 열 수있는 코드 ...

function FileOpen(strSetup) 
{ 
    if(! strSetup) 
    { 
     strSetup = ShowDialog("choose-setup", {"DialogTitle" : "Load Setup"}); 
    } 

    if(strSetup) 
    { 
     if(FileSystem.FileExists(App.Paths.Configs + "/" + strSetup + ".setup")) 
     { 
      var fFile = FileSystem.GetFile(App.Paths.Configs + "/" + strSetup + ".setup"); 
      App.Config = LoadXMLDocument(fFile.Path); 
      // SaveCurrentConfig(); 
      RefreshView("setup-summary"); 
     } 
     else 
     { 
      alert("Could not find setup '" + strSetup + "'"); 
     } 

    } 
} 

및 LoadXMLDocument에 대한 코드는 ... revision control이 모든 것입니다

//----------------------------------------------------------------------------- 
// FUNCTION : LoadXMLDocument - Loads an XML document 
// params : strPath - the path/file of the document to load 
//   : bCritical- if set true, we die if the document doesn't load 
// returns : an XML dom object on success, false otherwise 
//----------------------------------------------------------------------------- 

function LoadXMLDocument(strPath, bCritical) 
{ 
    var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); 
    xmlDoc.setProperty("SelectionLanguage", "XPath"); 
    if(! FileSystem.FileExists(strPath)) 
    { 
     Error("'" + strPath + "' is not a valid file path"); 
     if(bCritical) Abort(); 
     return(false); 
    } 
    var fFile = FileSystem.GetFile(strPath); 
    xmlDoc.load(fFile.Path); 
    if(xmlDoc.documentElement == null) 
    { 
     Error("Could not load XML document '" + fFile.Path + "'"); 
     if(bCritical) Abort(); 
     return(false); 
    } 
    return(xmlDoc); 
} 

답변

0

내가보기에 이것은 오래된 오래된 게시물이지만 VBS를 사용하지 않는 이유는 무엇입니까? HTA 인 경우 다음과 같이 함께 지원됩니다.

objFSO = CreateObject("Scripting.FileSystemObject") 

strFilePath = "C:\test.txt" 
If objFSO.FileExist(strFilePath) Then 
    MsgBox "I win" 
End If 
1

. 그것은 같은 문제의 다른 형태와 관련이 없습니다. hta 파일.

관련 문제