How can a drive (e.g. y) be mapped in C# to a network shared location? The mapped drive needs to be known by a SQL session. This is for backing up SQL databases from a C# application to the mapped drive (e.g. y). Would like to do it programmatically to allow easily changing the mapped drive network location, user and password.
Within SSMS / SQL session, I could create a mapped drive in a query window:
EXEC xp_cmdshell 'net use y: \\host11\special\temp temppassword /user:host11\sphr /persistent:no'
I could then backup the SQL Server databases from the C# application. Wondering, how do I do this in C#?