private void btnExportReg_Click(object sender, RoutedEventArgs e) { try { if (Registry.NativeRegistry.SaveKeyToFile( Registry.RegistryHive.HKLM, @"SOFTWARE\Microsoft\SecurityManager", "securitymanager.reg")) { MessageBox.Show("Success! Wrote " + NativeFileSystem.GetFiles("securitymanager.reg")[0].Size + " bytes to file."); NativeFileSystem.DeleteFile("securitymanager.reg"); } else { MessageBox.Show("Failed to save key! Error was " + NativeFileSystem.GetError()); } } catch (Exception ex) { MessageBox.Show("Exception occurred!\n" + ex.ToString()); } finally { //NativeFileSystem.DeleteFile("securitymanager.reg"); } }
public void TestGetFolder() { var root = NativeFileSystem.FolderBuilderFor(TestUtils.UniqueTempFolder()) .AddFiles("foo.txt") .EnterFolder("Bar") .AddFiles("bar1.txt", "bar2.txt") .LeaveFolder(); Func <string, string> rebase = path => Path.Combine(root.FullPath, path); var folder = NativeFileSystem.GetFolder(root.FullPath); AssertPathAndName(root.FullPath, folder); var fooTxt = folder.Children.OfType <IFile>().AssertSingle(); AssertPathNameAndParent(rebase("foo.txt"), folder, fooTxt); var bar = folder.Children.OfType <IFolder>().AssertSingle(); AssertPathAndName(rebase("Bar"), bar); var barFiles = bar.Children.Cast <IFile>().OrderBy(file => file.Name).ToList(); AssertPathAndName(rebase(@"Bar\bar1.txt"), barFiles[0]); AssertPathAndName(rebase(@"Bar\bar2.txt"), barFiles[1]); }
/// <summary> /// Runs the application. /// </summary> /// <param name="appPaths">The app paths.</param> /// <param name="logManager">The log manager.</param> /// <param name="runService">if set to <c>true</c> [run service].</param> /// <param name="options">The options.</param> private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options) { var fileSystem = new NativeFileSystem(logManager.GetLogger("FileSystem"), false); var nativeApp = new WindowsApp { IsRunningAsService = runService }; _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "MBServer", true, nativeApp); var initProgress = new Progress <double>(); if (!runService) { if (!options.ContainsOption("-nosplash")) { ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash")); } // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); } var task = _appHost.Init(initProgress); task = task.ContinueWith(new Action <Task>(a => _appHost.RunStartupTasks())); if (runService) { StartService(logManager); } else { Task.WaitAll(task); SystemEvents.SessionEnding += SystemEvents_SessionEnding; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; HideSplashScreen(); ShowTrayIcon(); task = ApplicationTaskCompletionSource.Task; Task.WaitAll(task); } }
static void TestFileSystem() { if (String.IsNullOrEmpty(NativeFileSystem.GetFileNames("D:\\*"))) { MessageBox.Show("File system access failed! Error " + NativeFileSystem.GetError()); } else { MessageBox.Show("File system access success!"); } }
static void TestPrivileges() { NativeFileSystem.DeleteFile("linktest.dll"); TokenPrivilege[] privs = Security.GetPrivileges(0); if (null == privs) { MessageBox.Show("Error getting privileges for current process! Error was " + NativeProcess.GetError()); } Security.TryGetCurrentToken(); NativeFileSystem.CreateSymbolicLink("Processes.dll", "linktest.dll", false); Security.GetPrivileges(0); }
static async Task Main(string[] args) { var fileSystem = new NativeFileSystem("."); using (var stream = fileSystem.Open("Program.cs", FileMode.Open, FileAccess.Read)) { using (var sr = new StreamReader(stream)) { Console.Write(sr.ReadToEnd()); } } //var manager = new ScriptModuleManager(); //await manager.ReloadAllAsync(); }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { MessageBox.Show("InitializeRoot returned " + NativeFileSystem.InitializeRoot()); //String sid = Security.GetChamberSid("CALC7"); //MessageBox.Show(sid); //MessageBox.Show(NativeProcess.CreateProcInChamber(sid, @"C:\Programs\Calc7\Calc7.exe").ToString()); //MessageBox.Show(NativeProcess.GetError().ToString()); //TestFileSystem(); //TestGetProcessIds(); //TestGetCurrentToken(); //TestPrivileges(); //TestLogonUser(); //TestFileSystem(); //TestProcessSearch(); }
private static async Task <bool> DownloadFilesToCache(string[] files) { for (int i = 0; i < files.Length; i++) { using (var app = (JSObject)Runtime.GetGlobalObject("App")) { app.Invoke("loadingProgress", i * 100 / (files.Length + 1)); } bool success = await NativeFileSystem.DownloadToCache(files[i]); if (!success) { return(false); } } return(true); }
private void TryInit() { if (!CheckAppPermissions()) { ShowInfoScreen("Access denied", "You have to grant file access permissions to continue!", true); return; } int storagePathLength; string rootPath = NativeFileSystem.FindRootPath(out storagePathLength); if (rootPath == null) { var storageList = NativeFileSystem.GetStorageList(); if (storageList.Count == 0) { ShowInfoScreen("Content files not found", "No storage is accessible.", true); return; } var found = storageList.Find(storage => storage.Path == "/storage/emulated/0"); if (found.Path == null) { found = storageList[0]; } ShowInfoScreen("Content files not found", "Content should be placed in " + found.Path + "<b><u>/Android/Data/" + Application.Context.PackageName + "/Content/</u></b>… or in other compatible path.", true); return; } if (!File.Exists(Path.Combine(rootPath, "Content", "Main.dz"))) { ShowInfoScreen("Content files not found", "Content should be placed in " + rootPath.Substring(0, storagePathLength) + "<b><u>" + rootPath.Substring(storagePathLength) + "Content/</u></b>…<br>It includes <b>Main.dz</b> file and <b>Episodes</b>, <b>i18n</b>, <b>Music</b>, <b>Tilesets</b> directories.", true); return; } RunGame(); }
protected override IFolderBuilder CreateFolderBuilder() { return(NativeFileSystem.FolderBuilderFor(TestUtils.UniqueTempFolder())); }
public WixScriptBuilder(TextWriter writer, string basePath, WixBuilderParameters parameters) : this(writer, NativeFileSystem.GetFolder(basePath), parameters) { }
public NativeFileSystemTests() { var root = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "../../../data/root")); _fileSystem = new NativeFileSystem(root); }