Should i use WSH, WMI, BAT? Any recommendations there?
Thanks, Taen Karth
Should i use WSH, WMI, BAT? Any recommendations there?
Thanks, Taen Karth
I am looking to accomplish the following task: Every 24 hours I would like something to delete all files in a specified folder older than, for example, 7 days with no user interaction. I was thinking of writing it as a script or a service or a small app...what would you recommend as a god solution for accomplishing this? I am leaning towards service but not sure how to create one...hehe
Thanks, Taen Karth
Thanks again that did it!:-D
Thanks, Taen Karth
That did it...and now i understand why...lol. Thanks for sticking through me with this one. I really appreciate it. Now i just have to remeber how to capture the button result from a messagebox button when clicked...lol I do believe I am a bit rusty now. Once again thanks fr the help!:-D
Thanks, Taen Karth
Jeez...now I get that error on this line: Dim Sw As New IO.StreamWriter(path & fileName, False)
and I do not get any errors on the two lines right before it that create adn delete the file.
Thanks, Taen Karth
Still the same "File is in use" error as before...
Thanks, Taen Karth
Ok tried that and still getting this error message:
The process cannot access the file 'C:\Documents and Settings\troy\Desktop\Projects\ChangeLogger\ChangeLogger\bin\Debug\ChangeLog.txt' because it is being used by another process.
This is what the "Save" event looks like now: Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbtnSave.Click Dim Sw As New IO.StreamWriter(path & fileName, False) IO.File.Delete(path & fileName) IO.File.CreateText(path & fileName) Sw.WriteLine(vbCrLf & MyString & vbCrLf & rtSummary.Text) Sw.Flush() Sw.Close() Me.Dispose() End Sub
Any ideas? btw thanks for the suggestions so far!
Thanks, Taen Karth
Nope. :confused:
Thanks, Taen Karth
Well that sure makes sense!...hehe My RTF box IS in fact gettnig all the text, What is happening is that when it gets to the line: IO.File.Delete(fileName) It states that it cannot perform the action because the file requested is still in use. Loop removed.
Thanks, Taen Karth
I have a simple project that i am trying to figure out how to complete. I have a .txt file that I am reading from. I would like to be able to read it into a RTF control change the text around and save it back. I was trying to make a shortcut and delete the file then create it and write the information from the RTF box or a stored string variable but no luck...something is holding the file open and I cannot figure out what it is. Code is below. Public Class Summary Dim path As String = Application.StartupPath & "\" Dim fileName As String = "ChangeLog.txt" Dim MyString As String Private Sub Summary_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Sr As New IO.StreamReader(path & fileName, True) Sr.BaseStream.Seek(0, IO.SeekOrigin.Begin) Do While Sr.Peek > -1 MyString = Sr.ReadToEnd Loop With rtSummary .ReadOnly = True .Text = MyString End With Sr.Close() End Sub Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbtnSave.Click Dim Sw As New IO.StreamWriter(path & fileName, False) If IO.File.Exists(path & fileName) Then IO.File.Delete(fileName) IO.File.Create(fileName) Sw.WriteLine(vbCrLf & MyString & vbCrLf & rtSummary.Text) Sw.Flush() Sw.Close() Else IO.File.Create(path & fileName) Sw.WriteLine(vbCrLf & rtSummary.Text) Sw.Flush() Sw.Close() End If Me.Dispose() End Sub Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbtnEdit.Click rtSummary.ReadOnly = False End Sub Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbtnClear.Click rtSummary.Clear() End Sub Private Sub Summary_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If rtSummary.Text IsNot "" Then End If End Sub End Class
I know that some of this has no relevance to the problem but i thought i would include it nonetheless. What is holding the fle open so i cannot delete it. Or...is there a better way to accomplish what I am trying to accomplish? Thanks in advance.
So how would I accomplish this task? or is there a better way other than RTF for saving and readin formatted text
Thanks, Taen Karth
I have created a very simple program that will basically keep and changelog file. I consists of three forms 1. Main menu form (New Change, Show Summary, Exit) 2. New Change form (textbox, 2 buttons, RT box) 3. Summary Form (RT box control) What I would like to happen: 1. When user clicks on New Change button in Main Menu I would like it to load the new change form. On the form there is a Textbox for name entry, a button that once clicked adds the name and timestamp to the RT box in Bold font, and a button for Save/Close. When I Save/Close I would like for the bold text in the RT Box to Append to the top of an existing .rtf file. 2. When user clicks Summary i would like the form to load the .rtf file in its entirety. (Read Only) Number two I don't have a problem with. Number one I cannot get to append. Here are the choices I ahve tried thus far: 1. Use the .SaveFile option. Works great but no Append option 2. Use a StreamWriter to write the information. This also works great but I cannot seem to get it to keep the RTF formatting. I have tried a lot of the Encoding types and it does not seem that a Streamwriter can write in RTF encoding. Am I wrong here? Please let me know in what direction I should head on this...=)
Thanks, Taen Karth
AHA! That's the stuff! I remember reading that before now. Thanks for bearing with me...:doh: and have a nice week!:-D Thanks, Taen Karth
hehe...sorry for the confusion but I, for the life of me, could not understand the logic of what was supposed to be happening. Now I understand it in theory and I am still too green to understand completely what you are telling me above. I have no Static Void method in my project. If this is just an invisible method?:wtf: that is assumed, how do I capture it? Thanks, Taen Karth
Yeah that is exactly what I mean. How does it discern the parameter and file that was passed to it and how do you code using it. I assume that the parameter it passes is the file system path to the file...which would enable me to use the .loadfile element of the richtextbox control to load the data. Just not sure how to capture the parameter... Thanks, Taen Karth
Obviously... When the programs opens it needs to load the file that called it as the default app to open in... My questions is how do you capture the file that opened it. When windows sets a program as default editor for a file type...when that file type is clicked and it opens the program how does the program know what called it? Thanks, Taen Karth
I don't think I quite explained it well enough. I am using a RichtextBox control and VB.NET 2005. I can read a .rtf fle into the richtextbox control using one simple command (.loadfile). There has to be a more straight forward way to accomplish this. Thanks, Taen Karth
I have developed a text editing software and I was wondering how to accomplish the following. I have set all .rtf files to open with my program by default in Windows I would like to know how to read the data from the .rtf file while my program opens Thanks, Taen Karth
Ok I think I need to break this down a little bit more for the relation: Table1 CustID - PriKey - linked to Table2(CustID) CustName Status Table2 CustID CustSiteID Table3 CustSiteID - PriKey - linked to Table2(CustSiteID) CustSiteName Addr1 Addr2 City State etc... I have relationships setup like above. I created a new DataSet Item from Add New Item in IDE. Then it asks me to select Tables which I select the three above. It then adds these three tables to the designer with relationships and TableAdapters configured and all. I then go to DropDownList1 and set the DataSource to the DataSet. It creates a binding source and then I set DisplayMember to CustName and it creates a new TableAdapter. Now I want to select a customer name in DropDownList1 and have it filter DropDownList2 so that only SiteName shows that has a relationship between CustID and CustSiteID. I can only get DropDownList2 to list all SiteName. I can't figure out how to filter it. Thanks, Taen Karth
This was posted in the VB forum as well since I was not sure which it pertained to. Ok, not sure exactly how to word this so here goes. I have a winform in my project that has the following: Controls 1. DropDownList1 - Customer Name 2. TextBox1 - Customer ID 3. DropDownList2 - Site Name DataBase Tables 1. tblCust - Fields(CustName, CustID, Status) 2. tblCustSiteAssoc - Fields(CustId, CustSiteID) 3. tblCustSite - Fields(CustSiteID, CustSiteName, ...) What I am trying to do is this: 1. When the form open have customers names bound to the DropDownList1 control with nothing selected 2. Once I select something in the DropDownList1 control (SelectedIndexChanged) have it update the other two controls with the selected customers' data. I assume I make a DataSet that queries all three tables and I understand how to bind the CustName to the first DropDownList box. What I don't understand is how to use the selected information to get the relevant information for the other two controls. Thanks in advance, Taen Karth Thanks, Taen Karth