Browsing 7239 questions and answers with Jon Skeet

sort files by size error in c#

I have a little problem sorting files. My program should allow me to sort the files of a directory by size and by date. The date works fine but when I try to sort by size, it...
Jon Skeet
people
quotationmark

DirectoryInfo.GetFiles already returns a FileInfo[] - so you don't need to convert each entry into a FileInfo using the constructor, as you're trying to do now. You can just use: ficheroo = dirInfoo.GetFiles(filtro,... more 6/17/2014 8:17:57 AM

people

JSON C# Parsing Error

This is my JSON { "3659639": { "EventID": 3659639, "RaceNum": 2, "Meeting": "Newton Abbot", "RaceType": "T", "Description":...
Jon Skeet
people
quotationmark

Currently, you're getting the properties of the properties - and then trying to cast each of the values to JObject, and then taking the Description of that. That's one level too deep, as you have: The root object Each property of the... more 6/17/2014 6:06:47 AM

people

Async/await flow

I have written the following (a plain Console application) to test my understanding about async and await in C#. public class Program { public static void Main(string[]...
Jon Skeet
people
quotationmark

Currently you're starting the operation - but it's never completing. Your program is terminating before you do anything with the task. As this is a console app, continuations will run on a thread-pool thread anyway, so you can change your... more 6/16/2014 6:18:27 PM

people

Object in ProjectReference not accessible when using 'Import'

In a simple project i want to reference objects from a webreference added to another c# library. The Webreference is called QServices The default namespace is set as below What...
Jon Skeet
people
quotationmark

I strongly suspect that for whatever reason, you're ending up with a namespace called QServices declared in the TaskWorkflow.SI namespace. So actually you want: using TaskWorkflow.SI.QServices; .... Record[] querysResult = new... more 6/16/2014 1:02:53 PM

people

CurrentThread.CurrentCulture and Unit Testing

I have a bug report where double.Parse(input) is throwing the following exception with the input "0.69803923368454": FormatException: Unknown char: . System.Double.Parse...
Jon Skeet
people
quotationmark

You've just picked a culture which happens to use . as a decimal point: var culture = new CultureInfo("ko-KR"); Console.WriteLine(culture.NumberFormat.NumberDecimalSeparator); // Prints . I typically use French (fr-FR) for this - and... more 6/16/2014 12:35:31 PM

people

REstful POST : Bytes to be written to the stream exceed the Content Length bytes size specified

This error gets thrown Bytes to be written to the stream exceed the Content-Length bytes size specified. when I run the following code: var request =...
Jon Skeet
people
quotationmark

The problem is that you're writing the UTF-8 BOM first, because Encoding.UTF8 does that by default. Short but complete example: using System; using System.IO; using System.Text; class Test { static void Main() { string... more 6/16/2014 12:13:11 PM

people

CLOB to binarystream conversion

How to convert Clob data to Binarystream ? I can able to find it in 2 steps as of now, 1-- CLOB to String 2--- String to BinaryStream. I am calling a SQL package which has 1...
Jon Skeet
people
quotationmark

Yes, there's no getBinaryStream method on Clob, because it doesn't make sense for there to be one. A clob is character data, not binary data. It makes no more sense to ask a clob for a binary stream than it does to ask a blob for a... more 6/16/2014 10:26:26 AM

people

Hijri Calendar in Windows Phone 8

I want to display some dates in the Hijri format in my Windows Phone 8 application. I found these classes HijriCalendar and CalendarIdentifiers.Hijri but they don't support...
Jon Skeet
people
quotationmark

You could use my Noda Time library, using CalendarSystem.GetIslamicCalendar to get the relevant calendar. Now, that may well have limitations in terms of: The rest of your application would ideally want to use Noda Time throughout, to... more 6/16/2014 8:57:43 AM

people

Associated Properties: How to Avoid an Infinite Loop

I have a Cube class. The cube can be constrained so that the width=height=length. I've coded this functionality but as you can see, my code results in a circular/infinite loop -...
Jon Skeet
people
quotationmark

Currently even just your getters will give a stack overflow - you don't have any fields backing your data, because you're not using automatically-implemented properties. Additionally, your properties don't have conventional names, which is... more 6/16/2014 6:28:39 AM

people

XML Parser return specific nodes

I have XML like that <?xml version="1.0" ?> <customers> <customer> <date>22 Aug 2014</date> <name>Kevin Anders</name> ...
Jon Skeet
people
quotationmark

I'd start off by removing your current code to retrieve a sequence of customers, and instead just use LINQ to XML: var customers = XDocument.Load(uri) .Root.Elements("customer") .Select(x... more 6/16/2014 6:24:52 AM

people