|
Hi,
After transferring PNG images to an FTP server, I am unable to open them as they are being corrupted. My code is as below:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://... etc.");
request.UsePassive = true;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("username", "password");
StreamReader sourceStream = new StreamReader(fileLocalDir);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
Another thing to add - when I download the file from the FTP server and open in IrfanView, the error below is displayed:
"C:\Folder\file.png: Can't read file header! Unknown file format or file not found! (For unicode file names, please activate the Unicode PlugIn in 'Properties -> Languages')"
Thanks for any assistance,
Anthony.
|
|
|
|
|
You're using the wrong type of stream. Maybe a BinaryReader would be better.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Thanks for your response Nagy.
I have modified my code to use BinaryReader .
I'm still able to transfer the files, but they end up being ~60% the size of the originals. I'm still unable to view the files due to corruption. Please can you advise whether my code is trying to do the right thing or not (see below)?
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftpuser...etc");
request.UsePassive = true;
request.UseBinary = true;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("username", "password");
BinaryReader br = new BinaryReader(File.Open(fileLocalDir, FileMode.Open));
FileInfo info = new FileInfo(fileLocalDir);
byte[] testArray = new byte[info.Length];
int i;
for (i = 0; i < info.Length; i++)
{
testArray[i] = br.ReadByte();
}
request.ContentLength = i;
try
{
Stream requestStream = request.GetRequestStream();
requestStream.Write(testArray, 0, i);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
}
Regards,
Anthony
|
|
|
|
|
i have created a crystal report with 3 table know i want to put a selection formula in a particular column of table but it is not working
what i have done is this
crystalReportViewer1.SelectionFormula = "{NewSampleEntrys.RecvdDate}={?EDOR}";
crystalReportViewer1.Refresh();
plz give some idea guys......
|
|
|
|
|
Hi all,
I'm trying to write a C# app to emulate the search functions in Windows Explorer, including "find in files" (otherwise I wouldn't need the help!)
I figure there must be part of the Win32 API that performs the find in files function for a set of files, but don't know the name. Can anybody give me any pointers?
Thanks,
Chris
|
|
|
|
|
c2423 wrote: I figure there must be part of the Win32 API that performs the find in files function for a set of files
Not that I know of.
c2423 wrote: Can anybody give me any pointers?
Indexed or non-indexed files? If it's indexed, you might want to interface with Windows Search[^]. Otherwise, it'd still be creating a list of files, and searching them the old-fashioned way.
I are Troll
|
|
|
|
|
Thanks for the response.
Unfortunately I've no control of whether files are indexed or not. I'll have a look at Windows Search though - maybe that will help a bit...
Not to sound completely stupid, but what do you have in mind when you say the old-fashioned way? I'm happy searching text files but not Word, Excel etc?
|
|
|
|
|
c2423 wrote: I'm happy searching text files but not Word, Excel etc?
That's why both Windows Search and Google Desktop employ plugins to index a specific filetype. To quote;
MSDN states: Windows Search currently supports the indexing of over 200 types of items (such as .txt, .html, and .xml file formats) and can work with multiple types of data stores (such as the NTFS file system and Microsoft Outlook).
Searching an index is also functionally different from searching a file; the index isn't updated continuously.
I are Troll
|
|
|
|
|
Interesting information. Looks like I might have to think of another approach to it by using plugins.
Thanks for the help!
|
|
|
|
|
You're welcome
|
|
|
|
|
If you just want to search through files, you might want to consider using the IFilter interface which allows you to read things like PDF files, Word docs and the likes. More details are here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
hi,
does anybody know how to render an image on the background of text in rich text box just like watermark.
Best regards
|
|
|
|
|
|
simply it doesn't work. it show white background.msdn says:
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
This property is not relevant to this class.
but thanks for attention.
waiting for other answers
|
|
|
|
|
You'd have to write your own Paint handler, as done in this[^] article
I are Troll
|
|
|
|
|
Hi,
I have a picture box and loaded a image. I zoomed the Picture box and tried to draw rectangle. when i draw rectangle downwards, picture box also moves down.
how to achive this...
Thanks in advance...
|
|
|
|
|
i want to use ajax in content page
i have script manager on master page
in content page i have following code
<asp:Content ID="Content2" ContentPlaceHolderID="MainContents" runat="server" EnableViewState="true">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>
<asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged ="checkchange" AutoPostBack ="true"/>
<asp:UpdatePanel ID="updatePnl" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" visible="false" ></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="CheckBox1" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
on server side i have following
protected void checkchange(object sender, EventArgs e)
{
if (CheckBox1.Checked)
{
TextBox1.Visible = true;
Label1.Text = Label1.Text + "HEllo";
}
else
{
TextBox1.Visible = false;
Label1.Text = Label1.Text + "bye";
}
}
problem is checkchange call just once
if i click towice on check box it does not works
|
|
|
|
|
Put the checkbox inside the updatepanel
|
|
|
|
|
i have try this but same problem and error is
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)
Timestamp: Mon, 26 Jul 2010 10:19:37 UTC
Message: Unknown runtime error
Line: 345
Char: 9
Code: 0
URI: http://localhost:4099/ScriptResource.axd?d=9I1lWtAvVqWN1mD9glifsmEaMOiOLiTKjnBQwe4NQFLjuZpRoCN_LRiI-oQlHO1ffCWMttDUGTSGUEn_n-0ZNQXbP7japojTJ_LVrzCwdLJYzGHv0-QESNieL9JuFlAo0&t=ffffffffec2d9970
Message: '__EVENTTARGET' is null or not an object
Line: 482
Char: 9
Code: 0
URI: http://localhost:4099/ScriptResource.axd?d=9I1lWtAvVqWN1mD9glifsmEaMOiOLiTKjnBQwe4NQFLjuZpRoCN_LRiI-oQlHO1ffCWMttDUGTSGUEn_n-0ZNQXbP7japojTJ_LVrzCwdLJYzGHv0-QESNieL9JuFlAo0&t=ffffffffec2d9970
Message: '__EVENTTARGET' is null or not an object
Line: 482
Char: 9
Code: 0
URI: http://localhost:4099/ScriptResource.axd?d=9I1lWtAvVqWN1mD9glifsmEaMOiOLiTKjnBQwe4NQFLjuZpRoCN_LRiI-oQlHO1ffCWMttDUGTSGUEn_n-0ZNQXbP7japojTJ_LVrzCwdLJYzGHv0-QESNieL9JuFlAo0&t=ffffffffec2d9970
Message: '__EVENTTARGET' is null or not an object
Line: 482
Char: 9
Code: 0
URI: http://localhost:4099/ScriptResource.axd?d=9I1lWtAvVqWN1mD9glifsmEaMOiOLiTKjnBQwe4NQFLjuZpRoCN_LRiI-oQlHO1ffCWMttDUGTSGUEn_n-0ZNQXbP7japojTJ_LVrzCwdLJYzGHv0-QESNieL9JuFlAo0&t=ffffffffec2d9970
Message: '__EVENTTARGET' is null or not an object
Line: 482
Char: 9
Code: 0
URI: http://localhost:4099/ScriptResource.axd?d=9I1lWtAvVqWN1mD9glifsmEaMOiOLiTKjnBQwe4NQFLjuZpRoCN_LRiI-oQlHO1ffCWMttDUGTSGUEn_n-0ZNQXbP7japojTJ_LVrzCwdLJYzGHv0-QESNieL9JuFlAo0&t=ffffffffec2d9970
Message: '__EVENTTARGET' is null or not an object
Line: 482
Char: 9
Code: 0
URI: http://localhost:4099/ScriptResource.axd?d=9I1lWtAvVqWN1mD9glifsmEaMOiOLiTKjnBQwe4NQFLjuZpRoCN_LRiI-oQlHO1ffCWMttDUGTSGUEn_n-0ZNQXbP7japojTJ_LVrzCwdLJYzGHv0-QESNieL9JuFlAo0&t=ffffffffec2d9970
Message: '__EVENTTARGET' is null or not an object
Line: 482
Char: 9
Code: 0
URI: http://localhost:4099/ScriptResource.axd?d=9I1lWtAvVqWN1mD9glifsmEaMOiOLiTKjnBQwe4NQFLjuZpRoCN_LRiI-oQlHO1ffCWMttDUGTSGUEn_n-0ZNQXbP7japojTJ_LVrzCwdLJYzGHv0-QESNieL9JuFlAo0&t=ffffffffec2d9970
how i can solve this
|
|
|
|
|
Hi all,
I have sat on the sidelines reading all your posts for a long time now. Up until now I have managed to hack my way through my own solutions by trial and error and looking here but now, i am a little lost for a solution to my current problem. Here is what i want to do.
Using C#
I have a word table sorted in order of the 1000 most commonly used words in the English language.
I want to read in from a text file, such as an Ebook or the likes and for each word read, store the numeric value representing its position in the lookup table in a tree like structure. I dont want to repeat words in the same depth in the tree, but realise they will be repeated at a later depth in the tree.
As i read in each sentence from the file, i want to check from the existing entries in the tree to see if the word exists.
In the case of a new start to a sentence I want to create a new root node and build on it accordingly, in the case of the begginings of the sentence
already being stored I only want to branch when a new word (and thus a new possible sentence path) is found.
that way any random sentence in the book could be recreated by traversing the tree by following the correct branches to the final child node.
I thought using the lookup table and storing ints would be a little more resource friendly rather than strings of words for each element.
So saving the following sentences would look like this...
The Boy Fell In the Mud
The Boy Fell In the Sand
The Boy Fell In the Water
The Boy Got Up Quickly
The Boy Got Up Slowly
The Boy Got Up To a lot of Mischief
The Boy Got Up To no good
The Girl....
Once upon a time...
Stores 2 dimensionally like this
The-Boy-Fell-In-the-Mud
-------------------------Sand
-------------------------Water
------------Got-Up-Quickly
------------Got-Up-Slowly
----------------------To-a-lot-of-Mischief
----------------------To-no-good
The Girl...
Once Upon a time...
Now to the question, I have been trying this using lists of lists but boy it is getting muddy.
I had a look at just using arrays but could not really work out how to do this effectively.
Considered hashtables??
So the question is, how would you guys approach this, create a class of some sort, persevere with the list of lists.
I confess I am a little lost at this point.
Any suggestions would be greatly appreciated.
Thanks heaps
Ray
|
|
|
|
|
Member 456249 wrote: I dont want to repeat words in the same depth in the tree, but realise they will be repeated at a later depth in the tree.
How about a treeview? I'm suggesting a visual component, because it might help in debugging, and it seems like the data would fit nicely.
I are Troll
|
|
|
|
|
I did have a bit of a fiddle with treeview, I suppose I could serialize it and write and read it back and forth as needed. I guess i was looking at it as more a visual thing, rather than a practical storage method? It might be interesting to visualise it that way now that I think about it. I might give that a shot. Thanks for that. Sometimes I miss the obvious and spend time on the obscure
|
|
|
|
|
Proffessor Lidenbrock wrote: I guess i was looking at it as more a visual thing, rather than a practical storage method?
That's how it's intended, yes. Alternatively, you could create your own tree-structure, kinda like this;
class MyWordNode
{
MyWordNode parent;
List<MyWordNode> children;
}
Start of with a rootnode (one with null as a parent). If you want to add a child to that node, add it to the list of children. That new node will also have it's own list of children, giving you a tree.
Abusing a treeview will save the time of writing your own tree
I are Troll
|
|
|
|
|
Hehe thanks, i like that, abusing treeview
Well since your first post I have made some progress. I have a tree that I can click and add and remove nodes. I have a loaded up the word list and have read into a normal listview the text file, making one sentence one item, removing all punctuation and non char entries.
Just tried to impliment a search threough the nodes of the treeview but crashed and burned on the first attempt. It is nearly 1 am. will try again tommorow. Thanks heaps.
|
|
|
|