|
Hello,
VS 2005
For some reason this simple bit of code doesn't work. it keeps throwing me an exception "Cannot create a file when that file already exists."
[CODE]For Each myFile As String In IO.Directory.GetFiles("G:\Temp1")
IO.File.Copy(myFile, "G:\Temp2")
Next myFile[/CODE]
I just want to move the files from 1 folder into another.
Many thanks for any suggestions.
Steve
|
|
|
|
|
You must already have the file "G:\Temp2". The code doesn't know what to do if the file already exists. If you want to replace the file, you will first have to check that the file exists, then delete it, and THEN move the file.
Hope this helps.
|
|
|
|
|
first of all you need to provide a name for the file to copy to
so:
dim myfilename as string()=myfile.split("\")
io.file.copy(myfile,"g:\temp2\" & myfilename(myfilename.length-1)) 'this is out of memory so could contain a mistake
second:
the error you get states that the file already exist (at the moment that because you try to override you map but you can get this when you run you'r program twice in a row)
you get this error because the override property is set to false on default
to change this:
io.file.copy(myfile,"g:\temp2" & myfilename(myfilename.length-1),true)
hope this helps
|
|
|
|
|
Hello,
thanks for the reply.
I manage to do it like this:
<br />
For Each myFile As String In IO.Directory.GetFiles("C:\Inetpub\wwwroot\PC8")<br />
filepath = String.Format("{0}{1}", physicalPath, myFile.Substring(myFile.LastIndexOf("\")))<br />
<br />
IO.File.Copy(myFile, filepath)<br />
Next myFile
If i have some folders in the same directory, which is the best method to copy them?
Many thanks,
|
|
|
|
|
for folders you can folow a simular way only you need to use getdirectories and createdirectory
see code below
For Each myFile As String In IO.Directory.GetDirectories("C:\temp")
Dim filepath As String = myFile.Substring(myFile.LastIndexOf("\"))
IO.Directory.CreateDirectory("c:\temp2" & filepath)
Next myFile
|
|
|
|
|
I have a case on an MDI form where there may be unsaved data and Im trying to allow the user to cancel the close process instead of just a Yes No answer.
Is there a way for me to know that the MDI form closed or didnt close?
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Handle the FormClosing event. You can ask the user whatever question you like and set the e.Cancel = True to stop the form from closing.
Mike Lasseter
|
|
|
|
|
Yes I do that but I also do some other activities in the Main Form and they seem to be done regardless of what happens in the form closing of the MDI.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
How are you handling the events in the main form? Are you responding to the FormClosing Event if so you should be monitoring the FormClosed Event. Besides guessing, I don't have enough information to help solve the problem.
Mike Lasseter
|
|
|
|
|
The main form does a Me.ActiveMDIForm.Close.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
I am assuming you have code that executes after the close call and you want to prevent this code from executing. I believe you have 2 options:
1. You can count the number of Mdi child forms that are being displayed before and after you call to AcitveMDIChild.Close. If the count changes you know the form closed otehrwise something has prevented to from closing.
2. Move all the code after the call to Me.ActiveMdiForm.Close to a different function that handles an event from the MDIChild when the form actually closes.
Hope that helps.
Mike Lasseter
|
|
|
|
|
Is there a property to allow the last column in a datagrid to be dragged, and hence expanded, past the bounds of the datagrid?
The issue is that the user has to double click the last column to resize it past the bounds of the datagrid.
I would like the column resizing to work in the same manner as windows explorer.
I have googled but to no avail.
Any help appreciated.
Guy
You always pass failure on the way to success.
|
|
|
|
|
how can i connect visual basics with oracle8.0
prashanna
|
|
|
|
|
|
Sql = "select * from tblSipFatMal where [SIP_TARIH] between DateSipTarBul1 and DateSipTarBul2"
Me.tblSipFatMal.FillSort = "[SIP_TARIH] DESC"
Me.tblSipFatMal.FillFilter = ""
this my prepare code.i have got two datetimepicker.i want between filter this datetimepicker..
can i help me?
|
|
|
|
|
shapinuva wrote: can i help me?
Doesn't look like it.
shapinuva wrote: DateSipTarBul1 and DateSipTarBul2"
This is never going to work. SQL is a different language to VB, your code needs to build valid SQL, the database cannot tell that these are variables within your VB code. So, your best bet is to write a stored proc, but if you want quick and dirty, just concatenate a string which includes the values of the dates in those controls/variables, instead of the names.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How can I convert the keyboard layout to arabic? I could covert the characters using the API 'LoadKeyboardLayout'. But the digits are not converting to arabic. I searched in the net for the API I understand the digits can convert with the function 'SetLocaleInfo'. This function receives 3 arguments but i don't know the value should be passed to this funtions. Please help to find the values of the arguments.
Thanks and Regards,
Mic
|
|
|
|
|
Dear all,
I would like to write a vb.net program that connect to LDAP and search the users from LDAP and display in text box or listbox. Thanks in advance.
RB
|
|
|
|
|
Use the ADSI[^] interface. Plenty of examples within that link.
|
|
|
|
|
Dear Craster,
Thanks for your help. But, what I have to implement is with LDAP. Could you please help with that ? If possible, I would like to get the sample coding.
Regards,
RB
|
|
|
|
|
ADSI supports LDAP, and there is plenty of sample code in the link I gave you.
|
|
|
|
|
Hi there
(vb.net)
I need to add drag/drop functionality to the webbrowser control. In vb6 it exposes a DragDrop event, it seems MS has made it redundant. I am now looking for another way to do this....by placing a transparent panel/usercontrol over the webbrowser control, and capture the drapdrop event in the panel. I have tried using a picture box, panel, as well as blank usercontrol with background set to Transparent, and I cannot get it to be transparent as run time.
1. Anyone know how I could implement a dragdrop event on the webbrowser control in vb.net?
2. If the above is not possible, how do I make a panel (or usercontrol) transparent?
Thank you
Regards
Dale
|
|
|
|
|
I don't think making a panel or uc transparent will work
if you put them transparent the events of the control will probably no longer fire (I'm not sure about it dough)
for drag and drop there are normally property's on the form and on the control for that:
allowdrop
and events:
dragdrop
dragenter
dragleave
dragover
I suggest u look at these
If you don't find it I have some code that does this but not with me at the moment (I'm at work) and I'm not sure I'll find it again (been a while since I wrote it back in my school days)
|
|
|
|
|
Transparent is not transparent. I know, just bear with me.
When you tell the BackColor of a control to be transparent, you're not telling the control to be transparent. You're actually telling it to take on the background properties of the controls parent container, in your case, the background of the form. That's why, by default, the background of the control turns gray, not "see through". This is why you can't see other controls between the form and the "transparent" control.
There's no way to "force" this to work using any property. You'd have to make your own version of the control you want to be "transparent" and render it, ALL OF IT, yourself. You'd have to provide all the drawing code to draw the entire control!
This also introduces a problem. Since in order to get an updated view of the "background" of your transparnet control, all the other controls under your will have to redraw themselves. This results in a performance problem because your redrawing just about the entire form to redraw your control.
|
|
|
|
|
Dear All,
I am using server/Client application which will communicate through winsock Control. Coding for all the database transactions done in the server application. Only the data is passed to Client. For each transaction client will request the Server to do the transaction.
Here my problem is between the transaction if Database is down/Network is down I am getting "End of communication channel/Oracle not available/TNS-packet failure" errors. I am using ADO connectivity for database transactions.
I tried by checking the socket.state, On Error goto. But nothing seems to be helpful. Any suggetions/Solutions are welcome
Thanks in advance
Regards
N.Surendran
|
|
|
|