|
This is something I see implemented incorrectly time and time again. The *correct* way to derive a key from a string password is using the System.Security.Cryptography.PasswordDeriveBytes method - it's usage is very straight forward.
|
|
|
|
|
Hello all -
I'm trying to write some code to read ID3 tags from mp3 files. ID3 stores information at *the end* of the mp3 file in 128 bytes.
I want to avoid having to loop through the entire file to get the data that I need but it appears that one only can read from the beginning of a file using the .NET I/O classes.
Is it possible to call a version of a Read method with an offset specifying where in a file you want to start reading into a byte array?
eg:
string path = "c:\\downers\\Mancini.mp3";
FileInfo fi = new FileInfo(path);
// the file length
long len = fi.Length;
// subtract 128
long start= len - 128;
int st = (int)start;
Stream fis = File.Open(path,FileMode.Open, FileAccess.Read);
BinaryReader re = new BinaryReader(fis);
byte[] data = new byte[128];
re.Read(data, start, 128); // this won't work, but you get my intuitions...
This doesn't work though; the offset argument in the middle of the read method is an offset in the byte array to start on.
Any ideas? Am I missing something obvious? Otherwise I just have code that loops through the entire file a byte at a time.
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
FileStream Mp3Stream = new FileStream(mp3File, FileMode.Open, FileAccess.Read);
Mp3Stream.Seek(-128, SeekOrigin.End);
|
|
|
|
|
Why is your code so long? Remember you can do most things with few lines of code.
You probably want something like this.
FileStream f = File.OpenRead("x");
f.Seek(-128, SeekOrigin.End);
f.Read(bytearray, 0, 128);
f.Close();
Also, you can get the length of the file just with f.Length;
Forget about using BinaryReader, David; it's for smart people. It allows you read/write different types like doubles, integers instead of working with bytes.
Thanks,
Wes
|
|
|
|
|
Thanks Wes,
very helpful. I 'discovered' seek a few minutes after posting
My code was a bit more lengthy because I was still feeling my way around the problem. Like usual, I should have cleaned up a bit before posting...
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
ID3V1 tag reading / writing has been done many times over in C# - a quick google search could save you a lot of time.
|
|
|
|
|
Are there any other methods to do printing in .net other than crystal reports and printdocument objects.
I want to print on non-standard papers,but did not find a better solution.
Thanks.
this is my signature for forums quoted from shog*9:
I can't help but feel, somewhere deep within that withered, bitter, scheming person, there is a small child, frightened, looking a way out.
|
|
|
|
|
What's the difference (if any) between:
[MethodImpl(MethodImplOptions.Synchronized)]
void SomeMethod()
{
}
and
void SomeMethod()
{
lock(this)
{
}
}
?
|
|
|
|
|
I don't believe there is any difference.
This is how lock is implemented.
object tmp = this;
Monitor.Enter(tmp);
try
{
DoSomething();
}
finally
{
Monitor.Exit(tmp);
}
For static methods, the class type is used instead of this.
From the specification, synchronized works the same as using lock(this) and lock(typeof(Class)) for statics around the method. I think both actually used the syncblockindex that every object has, so that mixed use will probably work correctly as well.
But in one Microsoft article on performance, it was suggested that synchronized function calls are faster than using locks. I think the reasoning used was that fine-grained locks are less performant--the higher-up the synchronization, the less overhead incurred because of fewer traffic lights.
My guess is that the implementation is actually the same.
|
|
|
|
|
I have tried several different ways to use this DLL, but can not get it to work. I have registered the DLL via regsvr32.
En/Decode MIME-Content with MimeSniffer
http://www.codeproject.com/internet/mimesniffer.asp?df=100&forumid=3772&noise=1&app=50&fr=51
The author only provides VB code for it and that does not help me much.
|
|
|
|
|
In the menu: Project->Add Reference, in here you select the COM Tab and select MimeSniffer.
Then it's just something like
MimeSnifferLib.Client ms = new MimeSnifferLib.Client();<br />
ms.CallAFunction();
I have not used MimeSniffer, so Client is probably called something else, but I hope you get the point...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Academic project. Free download from http://www.doteasy.addr.com
Abstract: "dotEASY" is a Visual Studio .Net Add-in that evaluates C# source code and performs "advices" in order to improve software quality. The configuration and programming of the "advices" is invisible to the developer, the tool’s final user, who only requests for code evaluation. A new "advice" can be created defining metrics, thresholds and optionally programming validation classes and execution classes to automatically modify the code. The export and import capabilities allow one person to create an "advice", which can be configured and exported, so it can be used by many other people.
Regards,
Juan Esteban Suárez
|
|
|
|
|
How to Click a Button in Another Application Programatically in C#?
|
|
|
|
|
Have you tried to raise the click event of the button?
But I'm not sure about crossing process threads, maybe use a Mutex.
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
I would like to write a simple syntax highlighter for one of my c# applications but i cant seem to find any examples on how to do this. My current plans are to use a richtextbox and somehow do the highlighting in this but i cant find any examples of how to use a richtextbox for something similar.
Does anyone know of any c# examples of syntax highlighters or if not any code snippets that might help me in writing one?
Thanks
Tim
|
|
|
|
|
|
I do have sharp develop but i was hoping for a much more simplistic view of it, i dont need it to do overly much at the minute but, i was hoping for something a lot less integrated and basic overview of how to do it.
Thanks all the same though
|
|
|
|
|
C#
Is it possible to declare reference variable?
I wanna change member variable of TextHandler class from Mouse class Basically I wanna keep reference to the member of another class).
public class Mouse<br />
{<br />
<br />
protected string strRefText;<br />
<br />
public Mouse(ref string strInText)<br />
{<br />
<font color=blue>this.strRefText = strInText;</font><br />
}<br />
<br />
public void AddMouse()<br />
{<br />
strRefText += "I'm mouse.";<br />
}<br />
}<br />
<br />
<br />
public class TextHandler<br />
{<br />
protected string strText;<br />
<br />
public void Main()<br />
{<br />
strText = "I'm dog. ";<br />
Mouse myMouse = new Mouse(ref strText);<br />
myMouse.AddMouse();<br />
Console.Write(myText);<br />
}<br />
}
|
|
|
|
|
Thomas W wrote:
// Add mouse text
public void Main()
{
strText = "I'm dog. ";
Mouse myMouse = new Mouse(ref strText);
myMouse.AddMouse();
Console.Write(myText);
}
Where is myText declared?
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
Not with strings, since they are immutable (their contents can't be changed), which means upon any change, a new string object is created, and any pointer to the previous one does not reflect the change (except when passing as a ref in a function call).
However, you can use a StringBuilder instead, who's contents can change without reallocating the class object itself. Your code idea will work with a StringBuilder, although that means all relevant code will have to use one.
|
|
|
|
|
Ok, Thanks for explanation.
|
|
|
|
|
Hi, all:
I am using Datagrid control in my WinForm application. I have two questions regarding the usage of the datagrid control.
1. In MS Access Database, you can specify a column "Lookup" to another table for available values ( show up as List when clicked on the cell ). Can I do the same thing in Datagrid control?
2. I'd like the user to update the data in the datagrid, but not add a new row. I will programatically add new rows through Dataset. Is this possible?
Thanks for your help in advance.
Dion
|
|
|
|
|
1. Yes. You can create class "DataGridComboBoxColumn" etc. using ComboBox and DataGridColumnStyle
public class DataGridUniPoleColumn : DataGridColumnStyle<br />
{ ... }
as it's written in help.
2. Property AllowNew (of DataView) to allow/deny adding new row by user is in ((DataView)ListManger.List) property (protected) of DataGrid -or- in Your view used by DataGrid -or- in DefaultView property of DataTable in the DataSet. You can add row to DataTable.Rows or to DataView using Add().
Your problems are much more complicated ... see help.
Hi,
AW
|
|
|
|
|
I'm trying to change the IP address of a Win2k machine, preferably without rebooting it, but there seems to be no info how to go about it!
Anybody any ideas ?
|
|
|
|
|
I have a dataset with two tables (Category, Element) and one relation between them (every row in Category has several rows in Element). At start I saw the Category lines and clicking the (+) sign could navigate to elements.
Problem: when a sublist of elements are shown corresponding to one catgory how can I know with wich category I work with (I need to know also the number of lines in the grid). If I want to iterate through elements I need to know the category.
Please help me!
|
|
|
|