WinForm Implement BS download folder upload operation

Source: Internet
Author: User

Experiment one thought of the folder upload in WinForm

Refer to the winform-> "using System.Windows.Forms in WebForm", which involves threading operations

The code is as follows Copy Code

[Directmethod]
public void Topbarclick (string stropearate)
{
Btnupdateeminfos (stropearate);
}
protected void Btnupdateeminfos (String stroperate)
{
if (stroperate = = "Import")
{

Thread s = new Thread (new ThreadStart (Folddialog));
S.apartmentstate=apartmentstate.sta;
COM provides a total of three threading models: single-threaded Apartment (STA single-Path suite), multithreaded Apartment (MTA multithreaded Suite) and neutral Apartment/thread Neutral apartment/neutral threaded Apartment (na/tna/nta neutral thread suite, provided by COM +).


S.setapartmentstate (System.Threading.ApartmentState.STA);
S.start ();

}
}

<summary>
Folder pop-up box
</summary>
private void Folddialog ()
{
Folderdialog d = new Folderdialog ();
String path = string. Empty;
if (d.showdialog () = = DialogResult.OK)
{
Path = D.path;
}
}

Folderbrowserfolder

The code is as follows Copy Code

Namespace CRM_BS.WebUI.Common
{
public class Folderdialog:foldernameeditor
{
Foldernameeditor.folderbrowser fdialog = new System.Windows.Forms.Design.FolderNameEditor.FolderBrowser { Startlocation = System.Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.Desktop};//logical Desktop
<summary>
Show folder Browser dialog box
</summary>
<returns></returns>
Public DialogResult ShowDialog ()
{
fdialog.description = "Please select folder";
return Fdialog.showdialog ();
}
<summary>
Gets or sets the description displayed above the folder
</summary>
<param name= "description" > folder above description </param>
<returns></returns>
Public DialogResult ShowDialog (string description)
{
Fdialog.description = Description;
return Fdialog.showdialog ();
}
<summary>
Folder target path
</summary>
public string Path
{
Get
{
return fdialog.directorypath;
}
}
~folderdialog ()
{
Fdialog.dispose ();
}
}
}

But the effect is as follows:

Pop-up is not active

Click the pop-up Effect

This is the effect, but the function is flawed ... The experiment is a failure (if you succeed, please let us know ...). )

Experiment two BS want this effect? That JS should be able to, start ...

First look at the effect:

Looks like it's satisfying the need.

Through the method, but also can smooth out the path

Look at the code again.

The code is as follows Copy Code

<%--Import--%>

<script language= "javascript" type= "Text/javascript" >
function Browsefolder () {
try {
var Shell = new ActiveXObject ("Shell.Application");
var folder = Shell.browseforfolder (0, "Please select Folder", 0); The starting directory is: desktop
if (Folder!= null) {
Folder = Folder.items (); Returns the Folderitems object
Folder = Folder.item (); Returns the FolderItem object
Folder = Folder.path; return path
if (Folder.charat (folder.length-1)!= "\") {
folder = folder + "\";
}
Document.all.savePath.value = Folder;
document.getElementById (savepath). value = Folder;
Hdpath.setvalue (Folder);
alert (Document.all.savePath.value);
Ext.net.DirectMethods.GetPath (Folder);
return Folder;
}
catch (e) {
alert (e.message);
}
}

</script>

Background code

The code is as follows Copy Code

//import
            (X.getctl ("Btntopbararrowdown") as Ext.Net.Button). Listeners.Click.Handler = "Browsefolder ();";

      ///<summary>
       ///Import- > Determination Method
       ///</summary>
        ///<param name= "path" ></PARAM>
        [ Directmethod]
        public void GetPath (string path)
         {
            Commonmethod.show ("", Path, Ext.Net.MessageBox.Icon.INFO);
       }

Although on the surface see "function realization, the code is concise, can say is very successful" but at the expense of IE security, need to make some settings.

Steps like Figure

One

Two

And look at the ActiveX encyclopedia.

"ActiveX is an open integration platform that provides developers, users, and web manufacturers with a quick and easy way to create program integration and content on the Internet and Intranet." With ActiveX, you can easily insert multimedia effects, interactive objects, and complex programs into your Web pages to create a high-quality multimedia CD-ROMthat is equivalent to the user experience.

So imagine what it would be like to have the ActiveX status set to "Enable" in order to achieve this function ...

Language often used to "back and forth", then return to the beginning of the problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.