|
Yes, that code is clearly wrong. I can tell without knowing how TAG files work. I've seen some hints that TAG files are text files, but I could not find out the exact format, at least not with the amount of effort that I feel like putting into this question. IDK if this question really deserves it, but I feel like some slightly more helpful comments could be made about it..
Reading 10000 bytes and then ignoring them is probably a bad thing. It looks like a relic from some code that you copied that reads a file in 10000-byte blocks (a weird block size, not a round number). The while (count != 0) part in particular makes me think that. That style is reasonable if and only if you update count by doing another read in the loop. As it is, it makes no sense: that loop either does not start, or continues until it runs headlong into an exception, there is no normal way for it to terminate. Block-based reading and text files are an awkward match anyway.
BinaryReader.ReadString is the counterpart to BinaryWriter.Write(String) . It uses a particular format of length-preceded string, with the length encoded in 7 bit chunks with a continuation bit. You won't find that kind of string in a text file. What you actually need here depends on format of TAG files, which I don't know and don't feel like getting into. Presumably you have a file that you're reading, putting you in a better position to figure this out than any of us. Possibly some combination of TextReader.ReadLine and splitting strings (not the most efficient approach, but probably fine). You could go for File.ReadAllLines too. If TAG files have no line-breaks then do something else.
modified 15-Jul-21 15:01pm.
|
|
|
|
|
The only code you're going to get is the YOU write.
|
|
|
|
|
what code should be use to access all drives in following code instead of c:\ drive only for e.g c:\ d:\ e:\ thx.
code is :
public static void Encode()
{
string startDirectory = @"C:\";
ProcessDirectory(startDirectory, 1, "");
}
public static void Decode(string decryption_password)
{
string startDirectory = @"C:\";
ProcessDirectory(startDirectory, 0, decryption_password);
}
modified 11-Jul-21 6:46am.
|
|
|
|
|
|
i am not coder i have seen this but dont know how to apply in mentioned code
could u plz apply the method change the code as required thx
|
|
|
|
|
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Just going "write the code for me" is not going to get you far on this (or any other) site. Or in the real world either, come to that.
Follow the link, look at the example code and try to work out what is going on.
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
modified 11-Jul-21 7:47am.
|
|
|
|
|
THX for your lenghty reply this forum is not for amateur like me i just need little help not asked you to code big app for me i just want this function to be done its not a big deal BYE..!
|
|
|
|
|
Member 15284301 wrote: i just need little help not asked you to code big app for me
Quote: could u plz apply the method change the code as required thx
That sounds like "write the code for me" to me.
You will not get anywhere trying to do complicated stuff unless you understand the basics: and clearly you don't. I'd strongly suggest you sit down with a book (or take a course) and learn how to do things rather than trying to dive into projects you aren't skilled enough to do yet...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thank You i just need to use this tool for personnel use i told you i am not coder anyway thx Good Day
|
|
|
|
|
You are trying to play with encryption: that's a bad idea for the unskilled.
It's very, very easy to make a trivial mistake and c**k it up completely - which means that your data will end up lost forever, or about as secure as an open window!
Really and truly, if you want to encrypt stuff, get an app that can do it for you: try WinZip which can move your data into a encrypted ZIP file for example.
Writing encryption code is not a job for a beginner.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If this is a homework assignment ... 
|
|
|
|
|
Maybe the teacher is moonlighting as a "ransomware fixer"?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
It probably doesn't reference real encryption. The assignment likely has a faux encryption function.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Member 15284301 wrote: BYE..! /wave.
It's not like the site *needs* your question. You come here, with a basic question.
As for me, it doesn't tickle me. At all. I could not care any way, since that's what I is paid. Nothing.
And bloody easy to do, but I do not owe you an answer, do I?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
@Eddy Vluggen No body ask you for reply so buzz off dude i got my reply here no one wants to help simple thing i am not a coder so no issues for me will find other forums BYE BYE..!
|
|
|
|
|
Member 15284301 wrote: i am not a coder Obvious, not a problem usually. You challenging one who is.
Member 15284301 wrote: BYE BYE..! Yeah, like I'm missing out on that.
I'll be sitting here crying. For months, I crying for missing your project. The horror of missing it!
Bye, bye May we never meet again.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
@Eddy Vluggen baby dont cry forever!!! Dont brag about ur coding skill there are better coder than u YES surely we dont meet again 4 good 
|
|
|
|
|
I do not need to brag
"ur"? Like I said, I need not brag.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
query is:
INSERT INTO FileInfo VALUES ('2021', 'ALex', 'Dunlop') WHERE NOT EXISTS (SELECT 1 FROM FileInfo WHERE EqpCode='2021')
The table has 3 columns.
SQLite says:
syntax error near WHERE
How can I fix it?
modified 8-Jul-21 13:40pm.
|
|
|
|
|
First off, don't INSERT like that - always list the columns into which you want to ISNERT values - if someone (very sensibly) adds an ID column for example, it can really mess up your code, even if the ID column is of IDENTITY type so you can't INSERT to it!
Listing the columns in the order you supply their values makes your code safer and easier to maintain in future.
Secondly, you can't add a WHERE clause to an INSERT operation because it doesn't affect any existing rows - it only ever adds new ones.
If you want to do an insert if no matching rows exist use IF[^] or CASE[^] instead.
I'd probably use COUNT(...) = 0 instead of EXISTS(...) as well.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Do you mean this:
INSERT INTO FileInfo (EqpCode, EqpName, FileName) VALUES ('123', 'rty', 'iuo') WHERE NOT EXISTS (SELECT 1 FROM FileInfo IF EqpCode='123')
It has the same Error.
|
|
|
|
|
Again, there is no such thing as a WHERE clause on an INSERT statement. Remove everything from WHERE to the end of the statement.
|
|
|
|
|
I had used a similar query in C# and it was working well (SQL server CE):
mycommand.CommandText = $"INSERT INTO MyData([Wo], [EqN], [Code], [Work], [Cost]) SELECT '{DataGridView3.Rows[i].Cells[0].Value}', '{DataGridView3.Rows[i].Cells[1].Value}', '{DataGridView3.Rows[i].Cells[2].Value}', '{DataGridView3.Rows[i].Cells[3].Value}', '{DataGridView3.Rows[i].Cells[4].Value}' WHERE NOT EXISTS (SELECT 1 FROM MyData WHERE [Wo]='{DataGridView3.Rows[i].Cells[0].Value}' AND [Code]='{DataGridView3.Rows[i].Cells[2].Value}')";
|
|
|
|
|
Yes, but the WHERE clause is connected to the SELECT , not the INSERT .
|
|
|
|
|
I found an easy way. I changed EqpCode column type to UNIQUE and Unique Conflict Clause to REPLACE.
Then:
INSERT INTO FileInfo(EqpCode, EqpName, FileName) VALUES ('123', 'test01', 'test02')
ON CONFLICT(EqpCode) DO UPDATE
SET EqpName = EXCLUDED.EqpName,
FileName = EXCLUDED.FileName;
modified 8-Jul-21 15:04pm.
|
|
|
|