コード例 #1
0
    private void uxbtnEdit_Click(object sender, EventArgs e)
    {
        var workingDirectory = Directory.GetParent(HostsFile.GetHostsFilename())?.FullName;

        if (workingDirectory == null)
        {
            return;
        }

        var startInfo = new ProcessStartInfo
        {
            UseShellExecute  = true,
            WorkingDirectory = workingDirectory,
            FileName         = "notepad.exe",
            Arguments        = HostsFile.GetHostsFilename(),
            Verb             = "open"
        };

        try
        {
            Process.Start(startInfo);
        }
        catch (Exception exception)
        {
            Debug.WriteLine(exception.Message);
        }
    }