AWS EC2 is a core part of AWS’s cloud platform, allowing users to spin up virtual machines for a variety of tasks; however, EC2’s offerings can be overwhelming. Learn the basics with our new AWS cheat sheet – this time on EC2!
'remove 1st column and its trailing white space Sub StepOne() Dim strCurrent As String = "" Dim strRoot As String = "" Try strCurrent = Directory.GetCurrentDirectory() 'strRoot = Directory.GetDirectoryRoot(strCurrent) 'strRoot = Directory.GetDirectoryRoot("\") Catch E As Exception 'Console.WriteLine("Error determining root directory") MessageBox.Show(E.Message) End Try 'read hostsfile.txt Dim strfileName As String strfileName = strCurrent & "\" & "hotlist.txt" Replace(strfileName, "\n1 ", "\n") End Sub 'GENERIC REGEX SEARCH & REPLACE. Use Regular Expressions to search/replace within file Function Replace(ByRef file As String, ByRef searchFor As String, ByRef replaceWith As String) As Boolean 'function used during Validation 'use Regular Expressions to search for and replace user defined variables Try Dim reader As New StreamReader(file) 'get a StreamReader for reading the file Dim contents As String = reader.ReadToEnd() 'read the entire file at once reader.Close() reader.Dispose() 'close up and dispose 'use regular expressions to search and replace text contents = Regex.Replace(contents, searchFor, replaceWith, RegexOptions.IgnoreCase Or RegexOptions.Compiled) Dim writer As New StreamWriter(file) 'get a StreamWriter for writing the new text to the file writer.Write(contents) 'write the contents writer.Close() writer.Dispose() 'close up and dispose Return True 'return successful Catch generatedExceptionName As Exception MessageBox.Show(generatedExceptionName.Message) Return False End Try End Function
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.