Editing file using CheckedListBox
Editing file using CheckedListBox
Editing file using CheckedListBox
Editing file using CheckedListBox
Editing file using CheckedListBox
Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox
Editing file using CheckedListBox Editing file using CheckedListBox
Editing file using CheckedListBox
Go Back  Xtreme Visual Basic Talk > > > Editing file using CheckedListBox


Reply
 
Thread Tools Display Modes
  #1  
Old 02-14-2012, 06:56 AM
Nucleus Nucleus is offline
Newcomer
 
Join Date: May 2005
Posts: 3
Default Editing file using CheckedListBox


(I accidentally posted this in legacy forums, please delete)



The idea is to comment and uncomment lines in the httpd.conf file to load and unload modules. This is what I have so far, working, but not always, somehow. But in any case, I don't think this is the proper way of doing this.

Any suggestions?

Thanks.

Code:
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        If CheckedListBox1.CheckedItems(0) = "mod_actions" Then
            IO.File.WriteAllText("C:\httpd.conf", IO.File.ReadAllText("C:\httpd.conf").Replace("#LoadModule actions", "LoadModule actions"))
        Else
            IO.File.WriteAllText("C:\httpd.conf", IO.File.ReadAllText("C:\httpd.conf").Replace("LoadModule actions", "#LoadModule actions"))
        End If

    End Sub
End Class
Reply With Quote
  #2  
Old 02-14-2012, 10:57 AM
passel's Avatar
passelEditing file using CheckedListBox passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

I would think, that if the person clicked the button more than once, and the checked item was not "mod_actions", then you would end up with multiple #'s in front of the phrase "LoadModule actions", one # for each time the button was pressed.
#LoadModule actions
##LoadModule actions
###LoadModule actions
etc...

Perhaps if you could replace the # with a space, and check for the space as part of the string, then you would only have one #.
" LoadModule actions"
"#LoadModule actions"

Or perhaps there is a "whole word" option on the Replace function which could be used. I didn't research it.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Editing file using CheckedListBox
Editing file using CheckedListBox
Editing file using CheckedListBox Editing file using CheckedListBox
Editing file using CheckedListBox
Editing file using CheckedListBox
Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox Editing file using CheckedListBox
Editing file using CheckedListBox
Editing file using CheckedListBox
 
Editing file using CheckedListBox
Editing file using CheckedListBox
 
-->