Use first argument as file. Set initial browser directory as the current one.
This commit is contained in:
@@ -16,6 +16,7 @@ namespace CsvView
|
|||||||
private void txtPath_DoubleClick(object sender, EventArgs e)
|
private void txtPath_DoubleClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OpenFileDialog loadDialog = new OpenFileDialog();
|
OpenFileDialog loadDialog = new OpenFileDialog();
|
||||||
|
loadDialog.InitialDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||||
DialogResult result = loadDialog.ShowDialog();
|
DialogResult result = loadDialog.ShowDialog();
|
||||||
if (result == DialogResult.OK)
|
if (result == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@@ -40,7 +41,13 @@ namespace CsvView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadedFile = txtPath.Text;
|
LoadFile(txtPath.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFile(string fileName)
|
||||||
|
{
|
||||||
|
_loadedFile = fileName;
|
||||||
|
txtPath.Text = fileName;
|
||||||
DateTime dtFile = File.GetCreationTime(_loadedFile);
|
DateTime dtFile = File.GetCreationTime(_loadedFile);
|
||||||
string indexFile = _loadedFile + ".idx";
|
string indexFile = _loadedFile + ".idx";
|
||||||
if (File.Exists(indexFile) && File.GetCreationTime(indexFile) > dtFile)
|
if (File.Exists(indexFile) && File.GetCreationTime(indexFile) > dtFile)
|
||||||
|
|||||||
19
Program.cs
19
Program.cs
@@ -1,22 +1,25 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace CsvView.Net
|
namespace CsvView.Net
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new FrmCsvViewer());
|
|
||||||
|
var frmCsvViewer = new FrmCsvViewer();
|
||||||
|
if (args.Length > 0)
|
||||||
|
{
|
||||||
|
if (System.IO.File.Exists(args[0]))
|
||||||
|
{
|
||||||
|
frmCsvViewer.LoadFile(args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Application.Run(frmCsvViewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user