two dlls + arguments

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to search a string in some text files.
(any good routines out there?)

then, I created a mysearch.exe with a method that will search for a String
in a fileName.
I want "string to search" and "fileName" to be the params in mysearch.exe /
method.
Is there any way to call mysearch.exe from another exe using
mysearch.exe("searchthisstring","inthisfile.txt")
if so... how?, any ideas or tips are accepted.
Thanks


The exception that is thrown when one of the arguments provided to a method
is not valid.
 
raulavi said:
I need to search a string in some text files.
(any good routines out there?)

Basic file reading samples (text, binary):

Reading a text file line-by-line or blockwise with a progress indicator
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=readfile&lang=en>

You can use 'InStr' to check if a certain string is contained in each line.
then, I created a mysearch.exe with a method that will search for a
String
in a fileName.
I want "string to search" and "fileName" to be the params in mysearch.exe
/
method.

\\\
Public Module Program
Public Function Main(ByVal Args() As String) As Integer
For Each Arg As String In Args
Console.WriteLine(Arg)
Next Arg
End Function
End Module
///

Select 'Sub Main' as startup object in the project properties.
Is there any way to call mysearch.exe from another exe using
mysearch.exe("searchthisstring","inthisfile.txt")
if so... how?, any ideas or tips are accepted.

\\\
Imports System.Diagnostics
..
..
..
Process.Start( _
"mysearch.exe", _
"""searchthis string"" ""inthisfile.txt""" _
)
///

BTW: Applications are no methods, so throwing an exception doesn't make
much sense. However, you can write an information message to the console
and set the exit code ('Return <exit code>') in 'Function Main'.
 
"raulavi"

Reading a text file line-by-line or blockwise with a progress indicator

Reading a text file line-by-line:

\\\
Imports System.IO
..
..
..
Dim Reader As New StreamReader("C:\WINDOWS\WIN.INI")
Do While Reader.Peek > -1
Debug.WriteLine(Reader.ReadLine())
Loop
Reader.Close()
///
You can use 'IndexOf' to check if a certain string is contained in each
line.

I hope this helps,

Cor
 
Roulavi,

I copied the wrong one

\\\
Imports System.IO
Imports System.Text
..
..
..
Dim Reader As New BinaryReader( _
New FileStream("C:\WINDOWS\WIN.INI", IO.FileMode.Open) _
)
Dim Buffer() As Byte
Me.ProgressBar1.Minimum = 0
Me.ProgressBar1.Maximum = Reader.BaseStream.Length
Dim BytesRead As Long
Const BlockSize As Integer = 1024 ' Read blocks of 1,024 bytes.
Do While BytesRead < Reader.BaseStream.Length
Buffer = Reader.ReadBytes(BlockSize)
Debug.Write(System.Text.Encoding.Default.GetString(Buffer))
BytesRead = BytesRead + Buffer.Length
Me.ProgressBar1.Value = BytesRead
Loop
Reader.Close()
///

You can use 'IndexOf' to check if a certain string is contained in each
line.

I hope this helps,

Cor
 
thanksmuch sense. However, you can write an information message to the console
and set the exit code ('Return <exit code>') in 'Function Main'. <<
Could you detail a litlle bit more on how to do it...I need to receive a
text...
(what is the statement that will return a string to my caller.)
what really goes into the caller and what goes into the called ...I know
this must be easy routines for many developers, but there are so many ways to
do it, and I need the one taht will always will.

Thanks again
 
thanksmuch sense. However, you can write an information message to the console
and set the exit code ('Return <exit code>') in 'Function Main'. <<

Could you detail a litlle bit more on how to do it...I need to receive a
text...
(what is the statement that will return a string to my caller.)
what really goes into the caller and what goes into the called ...I know
this must be easy routines for many developers, but there are so many ways to
do it
Thanks again



Herfried K. Wagner said:
Basic file reading samples (text, binary):

Reading a text file line-by-line or blockwise with a progress indicator
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=readfile&lang=en>

You can use 'InStr' to check if a certain string is contained in each line.


\\\
Public Module Program
Public Function Main(ByVal Args() As String) As Integer
For Each Arg As String In Args
Console.WriteLine(Arg)
Next Arg
End Function
End Module
///

Select 'Sub Main' as startup object in the project properties.


\\\
Imports System.Diagnostics
..
..
..
Process.Start( _
"mysearch.exe", _
"""searchthis string"" ""inthisfile.txt""" _
)
///

BTW: Applications are no methods, so throwing an exception doesn't make
much sense. However, you can write an information message to the console
and set the exit code ('Return <exit code>') in 'Function Main'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top