Solved

How do I specify a directory in ProcessStartInfo?

Posted on 2014-07-20
4
184 Views
Last Modified: 2014-07-21
I am downloading SQLExpress from my website and want it to be saved in a specific directory.  

Here is the code:

Dim p As New ProcessStartInfo
p.FileName = "http://desktophousewife.com/SQLEXPR_x64_ENU.exe"
' Start the process - Download and save file
Process.Start(p)
' save file in "C:\SQLDownload" ' or where ever you want then change the line below
MessageBox.Show("Press OK when download is complete")

I don't know how to do what is in bold.  Any help will be greatly appreciated!

Thanks.
0
Comment
Question by:Karen Wilson
  • 2
4 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 40207528
There is a WorkingDirectory property of the ProcessStartInfo but I don't know if that is what you need.  If it doesn't do what you want then I suspect it isn't possible.

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.workingdirectory%28v=vs.110%29.aspx
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 40208581
This will open the browser which would then prompt the user to decide whether to run the file, save it to disk or to ignore it. I think I mentioned in one of the previous questions that you can use My.Computer.Network.DownloadFile method to download it silently to whichever directory you want to.

http://msdn.microsoft.com/en-us/library/ack30t8y(v=vs.90).aspx
0
 

Author Closing Comment

by:Karen Wilson
ID: 40208652
Thanks!!  Works perfectly.  Yes, you did mention it previously but I was trying to figure out the silent load of SQL.  I'm combining it with the other code for smoother sailing.  Thanks again!
0
 

Author Comment

by:Karen Wilson
ID: 40210010
Code so someone else can use it:

Imports System.IO
Imports Microsoft.VisualBasic.FileIO
Imports System.Object
Imports Microsoft.VisualBasic.Devices.Network

My.Computer.Network.DownloadFile("http://yourwebsite.com/SQLEXPR_x64_ENU.exe", "C:\yourDirectory\SQLEXPR_x64_ENU.exe", "", "", True, 500, True)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now