Example #1
0
        static void initMyTempDir()
        {
            try
            {
                deleteUnusedTempDir();
            }
            catch
            {
            }

            int num = 0;

            while (true)
            {
                byte[] rand = Secure.Rand(2);
                string tmp2 = Str.ByteToStr(rand);

                string tmp = Path.Combine(Env.tempDir, "NET_" + tmp2);

                if (IO.IsDirExists(tmp) == false && IO.MakeDir(tmp))
                {
                    Env.myTempDir = tmp;

                    break;
                }

                if ((num++) >= 100)
                {
                    throw new SystemException();
                }
            }

            string lockFileName = Path.Combine(Env.myTempDir, "LockFile.dat");

            lockFile = IO.FileCreate(lockFileName);
        }
Example #2
0
 static void initValues()
 {
     exeFileName = IO.RemoteLastEnMark(getMyExeFileName());
     if (Str.IsEmptyStr(exeFileName) == false)
     {
         exeFileDir = IO.RemoteLastEnMark(Path.GetDirectoryName(exeFileName));
     }
     else
     {
         exeFileDir = "";
     }
     homeDir = IO.RemoteLastEnMark(Kernel.GetEnvStr("HOME"));
     if (Str.IsEmptyStr(homeDir))
     {
         homeDir = IO.RemoteLastEnMark(Kernel.GetEnvStr("HOMEDRIVE") + Kernel.GetEnvStr("HOMEPATH"));
     }
     if (Str.IsEmptyStr(homeDir))
     {
         homeDir = CurrentDir;
     }
     systemDir  = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.System));
     windowsDir = IO.RemoteLastEnMark(Path.GetDirectoryName(systemDir));
     tempDir    = IO.RemoteLastEnMark(Path.GetTempPath());
     winTempDir = IO.RemoteLastEnMark(Path.Combine(windowsDir, "Temp"));
     IO.MakeDir(winTempDir);
     if (windowsDir.Length >= 2 && windowsDir[1] == ':')
     {
         windowsDrive = windowsDir.Substring(0, 2).ToUpper();
     }
     else
     {
         windowsDrive = "C:";
     }
     programFilesDir      = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
     personalStartMenuDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu));
     personalProgramsDir  = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.Programs));
     personalStartupDir   = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.Startup));
     personalAppDataDir   = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
     personalDesktopDir   = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
     myDocumentsDir       = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
     localAppDataDir      = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
     userName             = Environment.UserName;
     try
     {
         userNameEx = Environment.UserDomainName + "\\" + userName;
     }
     catch
     {
         userNameEx = userName;
     }
     machineName    = Environment.MachineName;
     commandLine    = initCommandLine(Environment.CommandLine);
     osInfo         = Environment.OSVersion;
     isNt           = (osInfo.Platform == PlatformID.Win32NT);
     isCe           = (osInfo.Platform == PlatformID.WinCE);
     is9x           = !(isNt || isCe);
     isLittleEndian = BitConverter.IsLittleEndian;
     processId      = System.Diagnostics.Process.GetCurrentProcess().Id;
     isAdmin        = checkIsAdmin();
     initMyTempDir();
 }