|
You need first to get a count of the files and folders you're going to delete, then you just increment the progress bar after every delete call. Directory.GetFiles will give you a string array of files without that DirectoryInfo stuff. File.Delete will delete them. You should store the paths as you're counting them, so you don't need to get them twice.
It would work better to use a BackgroundWorker to do the deleting, and call it's ProgressUpdated event to update your UI, but calling Application.DoEvents() whenever you update the progress is easier and should work fine.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
I'm really stuck on this one.
I've got an mdi parent (with a single menustrip) + one mdi child (with no menu strips).
When I maximize the mdi child, it separates the mdi parent title bar and mdi parent menu bar, inserting a new line between them containing only the child icon and child control box.
Even stranger, when I close the app while a child is maximized, it distorts the size and location of the mdi parent (saved in My.Settings) by the height of this new "strip". So, repeatedly opening and closing the app with a child maximized causes the mdi parent to "creep" - the height decrements by the height of this mysterious "strip."
I have a tiny sample app to demonstrate the problem.
Can anyone help me out of this?
(I'm using VS 2005, vb.net 2.0)
Thanks.
Pat
|
|
|
|
|
I'll answer this one myself, just in case anyone else runs into it...
In VS 2005 designer, select the MDI parent form and set the MainMenuStrip property equal to the menu strip that you placed on the MDI parent. That's all it takes to merge child icons and child control boxes with the parent's menustrip! I don't recall this from VS 2003 (or .net 1.0) and it might be the source of much menustrip confusion in VS 2005 MDI.
|
|
|
|
|
And what error are you getting ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
I am using this basic code to run a DTS package.
Dim oPKG As New DTS.Package
With oPKG
.LoadFromSQLServer("DEV", , , _
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, _
, , , "HR_LoadData")
oPKG.Execute()
oPKG.UnInitialize()
oPKG = Nothing
End With
It works so great I would now like to run some DTS packages that reside in sql server on a different domain. What code do I need to get to a different domain?
|
|
|
|
|
I would like to ask what is the best db system that I can use to store data(ex:MDB or SQL)?
and secondly could some one tell me how to use the .mdb system I whet through a lot websites but non of those sites have a clear coding.
I found this one: but this just writes the columns, is there a practical way to use mdb.(I want to be able to use .mdb to its fullest capacity)
- any help is extremely appreciated -
ps:
can you also give me the codes to save data to db as well
(by the way I don't know anything about using db in vb .net)
------------------------------------------------------------------------
Try<br />
Dim ds As DataSet<br />
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;")<br />
'provider to be used when working with access database<br />
cn.Open()<br />
cmd = New OleDbCommand("select * from table1", cn)<br />
<br />
dr = cmd.ExecuteReader<br />
While dr.Read()<br />
TextBox1.Text = dr(0)<br />
TextBox2.Text = dr(1)<br />
TextBox3.Text = dr(2)<br />
' loading data into TextBoxes by column index<br />
End While<br />
ds = New DataSet<br />
D1.DataSource = ds.Tables<br />
Catch<br />
End Try<br />
dr.Close()<br />
cn.Close()
----------------------------------------------------------------------------
|
|
|
|
|
.mdb just means a microsoft access database which uses VB code behind it. SQL is a language to access data from a database such as SELECT * FROM TBL_CODEPROJECT. If your database is small Access is easier you don't have to code a lot for simple things. If you need a larger database then you can look at SQL Server (2003, 2005 or Express--which is free) to store your data then using something else (such as Access/VB, a .NET environment to access the data inside the database.
_________________________________________
You can't fix stupid, but you can medicate crazy.
|
|
|
|
|
thanks, can you give me the coding for both?
|
|
|
|
|
|
The old function:
Format(InputDateString, "00/00/00") would take in something like 032807 and return 03/28/07 .
I cannot seem to reproduce this with:
InputDate = String.Format("MM/dd/yy", InputDateString) or
OutputDateString= InputDateString.ToString("MM/dd/yy") Am I even close to figuring this out? I am trying to avoid the VB6 functions as much as possible.
As for the Mid() = that would be like saying:
Mid(InputRecord, 99, 5) = ReplacementString Is there a replacement for this other than
InputRecord = InputRecord.Substring(0, 99) & ReplacementString & InputRecord.Substring(99, InputRecord - 99)
-- modified at 8:55 Wednesday 28th March, 2007
Referring to the Formatting piece, if I first convert the string to a numeric value then use:
ConvertedValue.ToString("00/00/00") Then it works great how come I cant seem to get it to do anything from the original string?
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
1) For the mid function use Substring(startIndex(zero based), length)
Dim strOriginal As String = "My String"
Dim strSub As String = strOriginal.Substring(3, 2)'Returns "St"
|
|
|
|
|
I understand substring Im really asking about the replacement capability of the Mid function.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
The Mid function didn't do replacements. It just returned a substring from a string.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If you perform the following function:
Mid(InputRecord, 99, 5) = ReplacementString It will indeed substring out the piece you dont want and replace it at the same time with the new string.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Odd. It's not documented to do that. Testing in VBA reveals that it will only replace the exact number of characters specified in the original span. Using a different length string will only get cut off.
The closest equivilent in the .NET Framework is String.Replace() . Strings are immutable so any changes you make are not reflected in the original string, but in a copy of the string.
Dim s As String = "This is a test..."
s = s.Replace("is", "was")
The original string "This is a test..." is dropped while the Replace method returns a new string with the changes made.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I've seen people utilize the Mid for that functionality though, and you're right it is a fixed length but that is the intention for where it is used, at least where I currently work. I decided to modify what the other poster said and just do InputRecord = InputRecord.Remove(99, 5).Insert(99, ChangedInputValue) .
I am aware that the strings just create copies but this doesnt seem to be a large enough building scheme to utilize something else and like I said before I cant guarantee that the value at 99 for 5 is unique so a .Replace might have unforeseen consequences.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
It is documented, but there's the Mid function and the Mid statement. They are two completely different things.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
Oh crap. You're right. Shows you hong long it's been since I've touched VB6.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Sorry - did not read your post properly. Nothing I can think of that is as direct. You could use:
Dim s As String = "12345"
s = s.Remove(2, 2)
s = s.Insert(2, "xx") 'Returns "12xx5
I take it String.Replace(oldString, newString) is no good?
Hopefuly someone else posts with a better answer than mine...
|
|
|
|
|
Yes because I cant guarantee that the instance from 99 for 5 is unique.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Then you'll have to build the string back up using the available substring methods. The StringBuilder class would probably come in handy for that and save you from creating more String objects than is necessary.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hello all,
i wanted to have an application, which iclude a button, when clicking on it an existing word file will open in microsoft word.
I tried to add Microsoft Word 9.0 Object Library, from the COM in ADD REFERENCES, but the problem is that i dont have it in the references.
So whats the problem, any thing wrong in the .net i got? any thing wrong in the installation?
Any help is greatly appriciated ....
scorpion
|
|
|
|
|
do u have office 2003 or later installed?
|
|
|
|
|
Sorry for mis-mentioning, am using office 2003.
scorpion
-- modified at 9:34 Wednesday 28th March, 2007
|
|
|
|
|
Did you right-click References in Solution Explorer, Click Add Reference, and look under COM tab for "Microsoft Word 10.0 Object Library"
|
|
|
|