Login Form & File download (VB, VS05)

I have just started another project to distribute a file stored on my webserver (an excel spreadsheet).

But I don't want anyone to be able to access it, so..

I have...

1x Login Form
2x Windows Forms

They are all ready designed, but I would like to know how to preset a number of login usernames and passwords, so that the people who are authorized to view this file enter the info click ok and the main form would load from which they could download/view online it through this program.

I'm assuming the following code will work to 'view' in the default browser;

System.Diagnostics.Process.Start(http://url.com/book1.xls)

But is there a way I can set up a "download" command button, where it would save the file to a user selected location

I have no idea where to start on the login front and the other threads I've seen don't help. The same is with the "download" feature.

Many Thanks

Daniel 'fred' Munro



Answer this question

Login Form & File download (VB, VS05)

  • VoiceOfExperience

    one way to download the file is to use the HttpWebRequest/WebResponse class, or the WebClient class to download the file.

    http://msdn2.microsoft.com/en-us/library/system.net.webclient.aspx

    http://msdn2.microsoft.com/en-us/library/system.net.webclient.downloadfile.aspx

    so you could ask the user where to save it:

    Dim theSFD as new SaveFileDialog()

    if theSFD.ShowDialog() = System.Windows.Forms.DialogResult.OK then

    Dim theWebClient as new System.Net.WebClient()

    theWebClient.DownloadFile("Url", theSFD.FileName)

    end if

    and thats it!

    in regards to the login part - what are you having trouble with



  • Richard777

    well you could store them in a database and then when the user enters their username/password in the login form, it will check ot see if their username/password exists in the database. if so, then we are ready to go otherwise tell them that their credentials do not exist. Would this work for you

  • SomeDeveloperPerson

    I dont have any idea of how to "save" the usernames and passwords for a login, other than that the login form is ready to go..
  • Login Form & File download (VB, VS05)