3

如何在我的 Win 文件系统上创建隐藏文件?我读过你应该使用本机代码,我知道 AS3 有 NaviteProcess 类,但我真的不知道如何使用它,我也找不到太多关于它的信息。

有没有人知道怎么做?

先感谢您!

4

1 回答 1

3

清理以更好地反映我们的位置并将保持更新:

基于以下信息: http ://deepanjandas.wordpress.com/2010/09/10/writing-executing-cmd-scripts-through-air/

private var applicationDirectory:File;

private function createCMDFile():void
{
    applicationDirectory = File.desktopDirectory;
    var cmdFile:File = applicationDirectory.resolvePath( 'hide.cmd' );
    var stream:FileStream = new FileStream()
    stream.open( cmdFile, FileMode.WRITE );

    var dataString:String = "ATTRIB +H \\ C:\\Users\\***yourUserName***\\***fileToHide.txt***"; //or any path you want just be sure to use \\ instead of \ and obviously change ***yourUserName*** and ***fileToHide.txt***

            stream.writeMultiByte( dataString, "ANSI" );
    stream.close();

    stream = null;

    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
    nativeProcessStartupInfo.executable = cmdFile;

    var process:NativeProcess = new NativeProcess();
    process.start(nativeProcessStartupInfo);
    process.addEventListener( NativeProcessExitEvent.EXIT, onExitHandler );
}

private function onExitHandler( event:NativeProcessExitEvent ):void
{
    var cmdFile:File = applicationDirectory.resolvePath( 'hide.cmd' );
    cmdFile.deleteFile();
}
于 2012-05-08T01:33:11.190 回答