|
Thanks for the reply.
Is there a possible way to handle the if statement?
im not sure where to write the if statement, inside the while loop of the 2nd file or outside the while loop of the 2nd file??
|
|
|
|
|
Moving the IF statement won't achieve a lot. There's a lot more needed to fix the logic than that.
If you post your email address (not usually recommended) I can send you a possible solution - it's a bit big to post here.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
|
When you finish scanning the copy file you always need to output a line.
I still think there's a problem not showing up in your test data.
Suppose I have a file where the 5th and 10th lines match with the 10th having a later date. When the 5th line of the input is being processed, it will match the 10th line in the copy and the 10th line will be output. What happens when the 10th line of the input file is being processed? How do you know it's already been written out?
You seem to have introduced a new requirement. Namely, always write out lines that begin with '01' even when there are matching ones.
Try this as a test. Copy first 5 lines of above input, paste them into the file, somewhere in middle of file will do, and change the dates of the pasted lines to e.g. 27/04/2009. Do you get correct output?
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Reply for the first paragraph.
What u say is true, few lines may be written More than once.
For that case,Im writting code currently to remove similar lines.
Reply for the second paragraph:
I will not have this condition, because in my previous function before doing the parent-child, i have counted the similar lines and written as quantity field.
so there is no chance of parent starting with "01" to be repeated with diffeent dates.
|
|
|
|
|
It struck me that one way of thinking about this is that, having read an input line, if a match is found with a later date you just need to ignore the input line (the later dated one will be picked up in it's turn); otherwise you can write out the input line. This will do that.
Using sw As StreamWriter = New StreamWriter(oFile, False, System.Text.Encoding.Default)
Using sa As StreamReader = New StreamReader(iFile, System.Text.Encoding.Default)
File.Copy(iFile, "c:\DB\Output1\Similar1.txt", True)
temp = sa.ReadLine()
....
sw.WriteLine(sa.ReadLine())
While sa.Peek() >= 0
temp = sa.ReadLine()
....
If Trim(name).Substring(0, 2) = "01" Then
sw.WriteLine(name & child & desF & desAF & desA & desAA & ecn & dnf & baloon & dateTime & qty)
Else
Dim foundLaterMatch As Boolean = False
Using sa1 As StreamReader = New StreamReader("c:\DB\Output1\Similar1.txt", System.Text.Encoding.Default)
sa1.ReadLine()
sa1.ReadLine()
While (sa1.Peek() >= 0 ) AndAlso (Not foundLaterMatch)
temp1 = sa1.ReadLine()
.....
If name = name1 And child = child1 And dnf = dnf1 And baloon = baloon1 And result < 0 Then
foundLaterMatch = True
End If
End While
End Using
If Not foundLaterMatch Then
sw.WriteLine(currentLine)
End If
End If
End While
End Using
End Using
I've missed out lines that set name etc. and also dropped currentLine.
BTW Did you know that if you change each And in If name = name1 ... to AndAlso it will be slightly more efficient?
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
hello every one
i am using VS 2005
now i am having mdi form in that i am having 1 toolstrip menu item of backup which has the functionality of backup of my whole database
for that i wrote code like
imports system.io
Directory.CreateDirectory("c:\ backup")
Dim a As String = " c:\myproject\bin\debug\my.mdf"
Dim d As String = "c:\backup\my.mdf"
FileCopy(a, d)
MsgBox("backup Successfully")
but the problem is the directory name backup is created but data base is not copied in it
please help
|
|
|
|
|
I think the problem is
Directory.CreateDirectory("c:\ backup")
Remove the space after "\"
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
hello
i tried by removing space but still it doesnot copy my.mdf file to backup directory
please suggest...
thank you...
|
|
|
|
|
remove space from Dim a As String = " c:\myproject\bin\debug\my.mdf"?
|
|
|
|
|
If Not IO.directory.exists("C:\Backup") Then
IO.Directory.Create("C:\Backup")
End If
Dim a As String = "C:\Myproject\bin\debug\my.mdf"
Dim d As String = "C:\Backup\my.mdf"
IO.File.Copy(a,d)
MsgBox("Backup of 'my.mdf' was succesfull.")
This should do the trick.
Motivation is the key to software development.
|
|
|
|
|
hello
i tried with code you suggested but this is not working...
there is still no copy of my.mdf file is made to Backup folder..
just folder with blank data is created in c drive...
please suggest...
|
|
|
|
|
Does C:\Myproject\bin\debug\my.mdf exist?
Does C:\Backup\my.mdf exist?
|
|
|
|
|
Just curious, are you using Vista? If so, try running your program with Administrator priviliges
Cheers,
Zaegra
Motivation is the key to software development.
|
|
|
|
|
Hello,
do you use your database in your form? You won't be able to copy a open database.
Regards: Didi
|
|
|
|
|
Hi,
Iam using VS.2008 & looking to change programmatically, from Regional language setting [control pannel] date format to dd/MM/yyyy .
Any better ideas?
Thanks Again
|
|
|
|
|
I for one certainly wouldn't want any program to change my PC's regional settings.
Why would you want to programmatically change anything in the regional settings?
Why not just change the date format in your app ?
My advice is free, and you may get what you paid for.
|
|
|
|
|
Changing system-wide settings just to run your app is a VERY VERY VERY BAD idea.
|
|
|
|
|
Hi all,
Can I get folder full path on the computer by its name??
Thanks
|
|
|
|
|
Only if you search recursively across the machine and know for sure that there's only one folder with that name.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Thanks for your reply
I have another question, i made .net application and I add referance to another .net dll, i want to know if there is any way to geet dll path not application path??
Thanks
|
|
|
|
|
AFAIK, because you refered to that DLL it should be in the same folder as your application. So you could easily use Application.StartUpPath .
Example:
Dim DLLFileName As String
DLLFileName = Application.StartUpPath & "\yourfile.dll"
Where "yourfile" is replaced by the name of your DLL.
Hope this helps you out,
Zaegra
Motivation is the key to software development.
|
|
|
|
|
Thanks for help
but this solution didn't solve the problem, my .dll file is registerd as com component and i called it from vb6 modules, i want to get its physical path to read data from config file in the same path, can i get it??
Thanks
|
|
|
|
|
You could Assembly.GetExecutingAssembly, then call GetReferencedAssemblies on the result. That would give you an array of AssemblyName classes, which each have the CodeBase property. If you wanted to check whether they were COM references, you'd have to use Assembly.Load, passing the AssemblyName of the reference in question, and poke around somewhere to see if it has any COM types
Of course, all this presupposes that you're using VB.Net, not VB6. If you're using VB6, then this is irrelevant and you need help of the type nobody on a programming forum can give you
|
|
|
|
|
Not always. Depending on whether the Copy Local property is set or not, it might be referring to a path elsewhere in the file system. This is true even with COM wrappers - they could be generated, copied elsewhere, then the reference updated to that path, with Copy Local off
|
|
|
|