By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,019 Members | 1,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,019 IT Pros & Developers. It's quick & easy.

two dlls + arguments

P: n/a
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.
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"raulavi" <ra*****@discussions.microsoft.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a

"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
Nov 21 '05 #3

P: n/a
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
Nov 21 '05 #4

P: n/a
thanks
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'. <<
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

"Herfried K. Wagner [MVP]" wrote:
"raulavi" <ra*****@discussions.microsoft.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

P: n/a
thanks
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'. <<

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 [MVP]" wrote:
"raulavi" <ra*****@discussions.microsoft.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


"Herfried K. Wagner [MVP]" wrote:
"raulavi" <ra*****@discussions.microsoft.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.