|
That's not how your original post sounded, but OK.
The easiest way is using WMI and the System.Management namespace to create the share.
Win32_Share[^] WMI class docs
ManagementObject.InvokeMethod[^] docs
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave. You are right. I wrote some piece of code here, which does exactly what I need.
Since it's ASP.NET applicatioon I had some trouble in the beginning but then I found out that I need to import System.Management into my project and from there it was much better.
Try<br />
' Create a ManagementClass object<br />
Dim managementClass As System.Management.ManagementClass = New System.Management.ManagementClass("Win32_Share")<br />
' Create ManagementBaseObjects for in and out parameters<br />
Dim inParams As System.Management.ManagementBaseObject = managementClass.GetMethodParameters("Create")<br />
Dim outParams As System.Management.ManagementBaseObject<br />
' Set the input parameters<br />
inParams("Description") = "My Shared Files"<br />
inParams("Name") = partner_name<br />
inParams("Path") = Session("Path").ToString() ' This is a path to existing directory<br />
inParams("Type") = 0<br />
' Disk Drive<br />
' Invoke the method on the ManagementClass object<br />
outParams = managementClass.InvokeMethod("Create", inParams, Nothing)<br />
' Check to see if the method invocation was successful<br />
If (CType(outParams.Properties("ReturnValue").Value, Integer) <> 0) Then<br />
Throw New Exception("Unable to share directory.")<br />
End If<br />
Catch ex As Exception<br />
'Return e.Message<br />
End Try<br />
|
|
|
|
|
This is cool. Nice Post. Now, how do you automatically remove the share once it had been created (VB.NET code).
Dave
|
|
|
|
|
Is it possible to position (xy coordinates) the box that appears using messagebox.show?
Thanks
|
|
|
|
|
The short answer is no. A better option would be to create your own MessageBox class out of a normal form. You'll have all kinds of control over your own version.
The long answer is "with great effort", more than is required to make your own MessageBox class.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm trying to create an aplication in VB 2005 that automatically (just by clicking one button) opens a web page, inserts an ID and a password on two text fields, clicks a button in the page and then takes all the information from that page and shows it in the VB application.
My problem is that I dont know how to program my application to insert text and click buttons automatically.
I been checking the webresponse and webrequest classes but I have no idea if those can solve the problem.
Thanks
|
|
|
|
|
I need to check files for having no content. I will possibly be checking some large files, is checking for a .Peek return of -1 sufficient and faster for this purpose?
I just discovered My.Computer.FileSystem.GetFileInfo(File).Length = 0 which I suppose it probably the best way to go.
-- modified at 16:45 Tuesday 27th February, 2007
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Yup, I think checking the file size is the best way to go.
|
|
|
|
|
Hello
I am trying to put flashing text in lbl box in this project and i am new in ve.net i have try this code but it's not working so please can anybody help me how to do this
wating for your kind rep.
Private Sub btnBeep_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBeep.Click<br />
'toggle timer and botton text<br />
timBeep.Enabled = Not (timBeep.Enabled)<br />
If timBeep.Enabled Then<br />
btnBeep.Text = "&Stop Beeping"<br />
Else<br />
btnBeep.Text = "&Start Beeping"<br />
End If<br />
End Sub<br />
<br />
Private Sub timBeep_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timBeep.Tick<br />
Dim Flash As String<br />
Beep()<br />
If lblTimer.Text = Flash Then<br />
lblTimer.Text = ""<br />
Else<br />
lblTimer.Text = Flash<br />
End If<br />
End Sub<br />
End Class
|
|
|
|
|
According to your timeBeep_Tick procedure you have assigned an empty value to Flash variable and also in IF statement you are saying that if LblTimer.Text is empty and then set lbltimer.text to flash (what means to nothing). I think you should double check your IF statement. IF block will return LBLTimer.Text always empty because Flash value is not changing.
Tell me when Flash variable changes its value?
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Flash would need to be declared globally so it's value persists. You would initialize it when you start the timer so that it equals the text in the label. As an alternative you could set the text's font color to match the backcolor to hide it.
|
|
|
|
|
HuuuuuuuuuuReeeeeeeeeeeee
It' working i think this is my very stupid mistake , any way thanks very much for guiding me
thanks
|
|
|
|
|
Can you save a range of items in a listbox as a datatype, like a collection for adding to an Access Database??
If not then how do you loop thorough the listbox adding each one to a seperate column in an Access table?
Thanks
|
|
|
|
|
I belive what is more easy if you first save the values of listbox in an array, then send these datas to database by a cicle filling a recorset to update or with sql instructions.
Greetings from Mexico
-----------------------
Cuando salga el sol, no estare aqui...
|
|
|
|
|
Thanks, but im new to VB, can someone show me the code to do this?
|
|
|
|
|
I want to add a sound when a form loads, can I simply add the sound as a resource and then just make a statement like my.resource...blaablaablaa .play, or is it a lot more complicated than that?
Also, can i use mp3 or am i stuck with wav?
Cheers
|
|
|
|
|
Just use: My.Computer.Audio.Play(My.Resources.(YourFile), AudioPlayMode.WaitToComplete) .
harveyhanson wrote:
Also, can i use mp3 or am i stuck with wav?
Unless you want to embed Windows Media Player into your app (which would be a pain), you can only use .wav files. Hope this helps.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
can anyone help me to write a sample update query to update some text and interger fields in my database..i am using sql server 2000...
please send me a sample one that works.. so i can test it and modify it to use in my project...thanks.. having problem writing mine..
Nab
|
|
|
|
|
Why dont you post what you have so far and we can point you in the correct direction.
CleAkO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
its generated by webmatrix.. but its just not updating a field that is already in the table which has a string value...don't know why..
Dim queryString As String = "UPDATE [R_Application] SET [Fname]=@Fname, [Mname]=@Mname, [Lname]=@Lname WHERE (" & _
"[R_Application].[AppId] = @AppId)"
if the field was null then it works..but if some value exist..it doesn't update...
Nab
|
|
|
|
|
Is this the same query it always uses?
CleAkO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
yes same query..what wrong with it?... just do one and send it to me..let me try it
Nab
|
|
|
|
|
You have to show more of your code.
What you describe doesn't make sense if one only looks at the SQL query. An update query doesn't care if the value in the field is null or not, it updates the field in either case.
---
single minded; short sighted; long gone;
|
|
|
|
|
Ok..this is the exact query i am using....
Function testUpdate(ByVal appId As Integer, ByVal fname As String, ByVal lname As String) As Integer
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='TESTDBfhms'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "UPDATE [R_Application] SET [Fname]=@Fname, [Lname]=@Lname WHERE ([R_Application]."& _
"[AppId] = @AppId)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_appId As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_appId.ParameterName = "@AppId"
dbParam_appId.Value = appId
dbParam_appId.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_appId)
Dim dbParam_fname As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_fname.ParameterName = "@Fname"
dbParam_fname.Value = fname
dbParam_fname.DbType = System.Data.DbType.[String]
dbCommand.Parameters.Add(dbParam_fname)
Dim dbParam_lname As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_lname.ParameterName = "@Lname"
dbParam_lname.Value = lname
dbParam_lname.DbType = System.Data.DbType.[String]
dbCommand.Parameters.Add(dbParam_lname)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try
Return rowsAffected
End Function
Nab
|
|
|
|
|
There is nothing wrong with that code.
Debug the code and watch where you get the values from, as I suggested in the other thread.
---
single minded; short sighted; long gone;
|
|
|
|