FileNotFound Exception but file is there [closed] - c#

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
not much to explain as I have no logical explaination as to why this is not working :s
Just to confirm, It is a 'jpeg' file extention, the name is correct and I don't see any other issue with why it would not work be found.

You're saving it to a filename ending with "jpg" and then loading from a filename ending with "jpeg". Assuming you're trying to load the file you've just saved, that's the problem.
(I'd copy the code to point out the lines in question, but you only included it as an image...)
I'd strongly suggest constructing the filename once, and using that variable twice:
// I prefer using Path.Combine over string concatenation, but both will work.
// You might want to change "Identitys" to "Identities" though :)
string file = Path.Combine(#"C:\", "SimpleSkype", "Identitys", dd + ".jpg");
SaveSkypeAvatarToDisk(u.Handle, file);
using (Image image = Image.FromFile(file))
{
...
}

Related

How to replace "\\" to "\" with String.Replace() [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I want to replace "\\" with "\" (two to just one).
I'm using:
string myPath = Path.GetFullPath(fileName);
string correctPath = myPath.Replace(#"\\", #"\");
But nothing happens, the string in correctPath continues with "\\"
You're probably viewing the string whilst paused in the debugger. Print the value to a console window, it's fine.
string myPath = #"hello\\world";
string correctPath = myPath.Replace(#"\\", #"\");
Console.Write(correctPath);
Console.Read();

How to save all words above 7 letters to a file [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I am currently working on a console text analysis program for an assignment.
My problem is, I need to save all user entered words above 7 letters to a text file. The user can enter words by typing in their paragraph or by loading from a text file.
Any ideas on how I can do this ?
Thanks for any help in advance
Without giving you the code, think about what you really need to do.
Read in the entire text.
Split the text based on spaces / punctuation to identify each word. This will be stored in an array.
Test each split string's length.
Write the results to a file.
I'm not sure how you're getting the user-entered words, but you can do a simple LINQ statement to get the words greater than 7 letters:
//get all words into an array (wordArray)
var bigWords = wordArray.Where(w => w.Length > 7).ToArray();
Then you do something with the bigWords array.
I'm not going to do your assignment for you.
You should check functions such as String.Split, String.Length and String.Substring()

Looking for SpanIncluding equivalent in C# [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I'm porting a c++ class to C# and i have a difficulty.
I would like to find an equivalent of SpanIncluding.
Here is my cpp code :
while (Notes.Mid(j,1).SpanIncluding("0123456789").IsEmpty()!=NULL){}
Anyone can help me please ?
I believe SpanIncluding starts matching from the start of the string, stopping when the first non-matching character is found.
So one formulation in the general case would be this:
string match = new string(someString.ToCharArray().
TakeWhile(c => "0123456789".Contains(c)).ToArray());
(or an equivalent using a regular expression).
However, in the example given in the question there's only one character so the whole thing probably boils down to a test of whether this character is >= '0' and <= '9':
while(char.IsDigit(Notes[j])) { ... };
I found the MSDN page for SpanIncluding, and it seems like a ridiculously specific function. I can't really understand what it tries to solve, since it has some strange caveats.
LINQ would be one way of implementing it:
string text = "2334562";
IEnumerable<char> spannedChars = text.TakeWhile(c => "1234567890".Contains(c));
This is a more direct port of SpanIncluding than queen3's option, if I understand the MSDN page correctly, because the result set should stop the minute it hits a character not in the spanning string.

Image URL is not working [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have this piece of coding which is supposed to receive a URL as a string and this URL is supposed to be set as the Image Url :-
Heres the code
foreach (SPListItem item in oSpListCln)
{
if (item.Title.Equals("Rubicks"))
{
Title.Text = item.Title;
lblSyp.Text = item["Sypnosis"].ToString();
PicPic.ImageUrl = item["PicPic"].ToString();
}
}
The value of item["PicPic"] is http://www.froot.nl/wp-content/uploads/quick-brown-fox-froot.jpg,http://www.froot.nl/wp-content/uploads/quick-brown-fox-froot.jpg
This doesn't work is it cause I'm setting a string as a URL of an image cause when I hard coded the link it worked but when I set the link to a string and try, it doesn't. Does anyone know a way of how to do this?
Given that the returned string is comma-separated as you wrote in comments, you could do something like:
string[] urlParts = item["PicPic"].ToString().Split(',');
PicPic.ImageUrl = urlParts[0];

How can you know if a stream is closed? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have a method with a Stream for input :
public void Export(Stream finalOutPutStream)
For test purposes, i call it with a memory stream, like this :
// When
_exporter.Export(new System.IO.MemoryStream());
But when, in the method, i want to write on this memory stream, i get a ObjectDisposedException.
This stream is not enclosed in a using statement, i do not call explicitely .Dispose().
What happened ?
Thanks :)
--
EDIT : my bad, the problem is from the third party writer (DotNetZip). The exception happens when i call zip.Save(new MemoryStream()). I will ask my questions on their forum.
Sorry, and thanks for the help.
You can check stream availability using: CanRead, CanSeek, CanWrite properties.
if you put the stream creation inside using it will do the closing and resource release for you
EX:
using(Stream s = new MemoryStream())
{
// do your operations
}

Categories

Resources