我正在使用 HTML 标签将文件上传到服务器:
<input type="file">
Run Code Online (Sandbox Code Playgroud)
当我单击浏览按钮时,它会显示一个文件打开对话框。我可以通过将扩展过滤器传递到该对话框来过滤文件吗?就像我们可以在 .Net 框架的文件打开对话框中传递以下内容:
Text files *.txt|.txt
Run Code Online (Sandbox Code Playgroud)
使用此过滤器我们只能打开.txt文件。其他不向用户显示的文件。这个对话框有选项吗?
我试图在新线程中使用openDialog,但它做了如此奇怪的行为..
如果我把if opendialog.execute然后放在create构造函数中,如下所示:
constructor TChatMemberThread.Create(Name: string);
begin
inherited Create(True);
FName := Name;
FreeOnTerminate := True;
Opendialog := TOpenDialog.create(nil);
if opendialog.execute then
for 0 to opendialog.filescount do
somecodeishere
end;
end;
Run Code Online (Sandbox Code Playgroud)
opendialog正常打开但是当我把它放在线程的执行生成器中时它根本没有打开!!
我是线程的初学者,所以任何人都可以向我解释发生了什么?
提前致谢 .
[编辑]
unit Unit1;
interface
uses
Classes,Dialogs,ComCtrls,SysUtils,DCPcrypt2, DCPmd5;
type
TOpenThread = class(TThread)
private
{ Private declarations }
OpenDlG : TOpenDialog;
LI : TListItem;
Procedure Openit;
Function MD5it(Const filename : string ):String;
protected
procedure Execute; override;
Public
Constructor Create;
Destructor Destroy;Override;
end;
implementation
uses Main;
{ TOpenThread }
Constructor …Run Code Online (Sandbox Code Playgroud) delphi multithreading delphi-2009 fileopendialog topendialog
在下面的代码我设置ofd1.RestoreDirectory为false不过,该对话框打开inital目录每次.有什么东西我不知道吗?
private void btnMeshFile_Click(object sender, EventArgs e)
{
OpenFileDialog ofd1 = new OpenFileDialog();
ofd1.Title = "Open";
ofd1.InitialDirectory = @"c:\";
ofd1.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
ofd1.FilterIndex = 2;
ofd1.RestoreDirectory = false;
if (ofd1.ShowDialog() == DialogResult.OK)
{
string fileName = Path.GetFileName(ofd1.FileName);
MeshDirectoryPath = Path.GetFullPath(ofd1.FileName).Replace(@"\", @"\\");
txtMeshFile.Text = fileName;
}
}
Run Code Online (Sandbox Code Playgroud)