我想设计一个包含浏览按钮的程序,我们可以浏览到所选文件夹并打开文件夹内的文件.
我需要一个参考和阅读,我可以解决我的问题?喜欢我应该使用什么方法/类.我不喜欢从MSDN上读书,因为我很难理解他们的理论.仅供参考我仍然是C#的初学者.
非常感谢你
P/s:这是我从互联网上找到的代码,您可以浏览/创建新文件夹.但我不知道为什么它使用Shell32.dll ..
private void button1_Click(object sender, EventArgs e)
{
string strPath;
string strCaption = "Select a Directory and folder.";
DialogResult dlgResult;
Shell32.ShellClass shl = new Shell32.ShellClass();
Shell32.Folder2 fld = (Shell32.Folder2)shl.BrowseForFolder(0, strCaption, 0,
System.Reflection.Missing.Value);
if (fld == null)
{
dlgResult = DialogResult.Cancel;
}
else
{
strPath = fld.Self.Path;
dlgResult = DialogResult.OK;
}
}
Run Code Online (Sandbox Code Playgroud) 是否有关于如何在C#中打开或执行某些窗口程序的解决方案/参考?例如,如果我想打开WinZIP或记事本应用程序?
代码行上的示例更有帮助.但欢迎任何事情.
谢谢.
我想设计一个ac#程序,可以运行程序第三个exe应用程序,如WinRAR.程序将浏览文件,然后当用户单击按钮时,创建存档的过程将开始..!
我知道使用System.Diagnostics.Process.Start方法可以执行.exe文件.例如.
Process.Start(@"C:\path\to\file.zip");
GetFile("文件名","打开winrar来执行文件")我需要这样的东西.我想将文件名传递给第3个应用程序,而无需打开winrar.可能吗?我该怎么开始?任何参考/指导/解决方案都非常感谢.
非常感谢你.
//更新
下面是打开WinRAR.exe程序的代码,否则会出现错误消息.我在button_click中点击它并使用browse从txtDest.text接受文件.所以从这里开始,我想直接压缩,而不是打开文件.我尝试更改"RAR.exe"或"UNRAR.exe",但它没有工作.这是正确的?
谢谢.
ProcessStartInfo startInfo = new ProcessStartInfo("WinRAR.exe");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
startInfo.Arguments = txtDest.Text;
try
{
// Start the process with the info we specified.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
MessageBox.Show("Error Open");
}
}
在我们上传文件之前,有人可以指导我如何检查以确定文件是否已存在于数据库中?
我想将一个文件上传到数据库,但在保存之前,我想先查看已存在的文件.如果是,那么不要执行插入执行.
我在上传文件时使用了这个参考.
非常感谢你.
我需要有关如何过滤数据库中的数据的帮助.我想要一个像excel电子表格中的过滤器.
例如,我有关于如何从w3school获取有关如何从数据库中选择数据的数据的示例代码.这是我的示例代码:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("TableTest", $con);
$result = mysql_query("SELECT * FROM Colors ");
echo "<table border='1'>
<tr>
<th>Colors</th>
<th>Type</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['colors'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
Run Code Online (Sandbox Code Playgroud)

我也在w3school中发现了这个样本,但我不想用下拉过滤数据库.
我想把它变成一个excel过滤器.当我选择"颜色"列以过滤"红色"时,它将仅显示红色.所以我想知道是否有人可以帮助我如何开始.
谢谢大家
该程序将表1中的所有记录复制到表2中,并写入文本文件.完成复制所有记录后,将删除记录,使table1为空,然后再添加新记录.我喜欢增强我的代码,例如:
先感谢您!
//create connection
SqlConnection sqlConnection1 =
new SqlConnection("Data Source=.\SQLEXPRESS;Database=F:\Test2.mdf;Integrated Security=True;User Instance=True");
//command insert into queries
SqlCommand cmdCopy = new SqlCommand();
cmdCopy.CommandType = System.Data.CommandType.Text;
cmdCopy.CommandText = "INSERT INTO tblSend (ip, msg, date) SELECT ip, msg, date FROM tblOutbox";
cmdCopy.Connection = sqlConnection1;
//insert into text file
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM tblOutbox";
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
StreamWriter tw = File.AppendText("c:\INMS.txt");
SqlDataReader reader = cmd.ExecuteReader();
tw.WriteLine("id, ip address, message, datetime"); …Run Code Online (Sandbox Code Playgroud)