|
Hello,
How we can test if a directory is empty? thank you verry mutch.
|
|
|
|
|
If Directory.GetFiles[^] is not returning any data, consider it is empty.
Best wishes,
Navaneeth
|
|
|
|
|
const string MYDIR = @"C:\MYDIR";
string[] files = Directory.GetFiles(MYDIR);
string[] dirs = Directory.GetDirectories(MYDIR);
if(files.Length == 0 && dirs.Length == 0)
{
}
|
|
|
|
|
Hi,
before .NET 4.0:
the easiest way is testing Directory.GetFileSystemEntries().Length==0 as this method returns the names of all files and folders.
and yes it is a pity you have to ask for a potentially huge array of data just to get a true/false result.
the alternative is to use P/Invoke and use FindFirstFile (not sure if and how that works for subdirectories).
since .NET 4.0 there are new siblings to GetFileSystemEntries and the like (see EnumerateFileSystemEntries) that return results only one at a time and don't burden the CPU and memory that much, as you can opt out right away.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
I want totransfer files from a client to another, using socket programming+c#?
|
|
|
|
|
So on what part are you facing problem?
Best wishes,
Navaneeth
|
|
|
|
|
never heard about google ?
you can find also in codeproject, there are lots of sample for that.
|
|
|
|
|
Hi
I am writing a small class that covers a multitude of areas for CD use.
I am using IMAPI2, and managed to get the buring, formatting and erasing process going, but I haven't been able to find anything for reading from a disc.
Does IMAPI2 do this, or is there another way of doing this?
Please help!
Thanks
|
|
|
|
|
|
Hi
I know about this article, but it does not provide for reading data from a CD into an application, which is what I want to do.
The solution, I am looking for is a way to read data off a disc into a database. Therefore, I need to stream data off a disc into a object.
Thanks
|
|
|
|
|
|
Hello,
I frequently write many SQLs and would like to embed in C# code (SSMS 2005/VS.NET 2005). There was macro which would let me select the code and hit a shortcut to format it into C# code. Has anyone seen where it is now?
Thanks,
Raghu.
You can never try. You either do it or you don't.
|
|
|
|
|
Do I understand that you want a macro to copy SQL statements into a C# file?
I thought it was Ctrl+C, Ctrl+V
only two letters away from being an asset
|
|
|
|
|
Hmm... haven't heard that before, but I'll give it a try...
I was referencing converting a SQL statement to C# string...
But, here's what I came up with in case someone needs this... Assign this macro a short cut of of Ctl+Shift+F3
It converts
select *
From Status
From ActivityStatus ActStsId=StsId
to
string sql = " select * "+
" From Status "+
" From ActivityStatus ActStsId=StsId";
Macro is as follows.
Sub SQL2CSharp()
Dim selection As EnvDTE.TextSelection
Dim startPoint As EnvDTE.EditPoint
Dim endPoint As TextPoint
Dim quoteStart As String
selection = DTE.ActiveDocument.Selection()
startPoint = selection.TopPoint.CreateEditPoint()
endPoint = selection.BottomPoint
quoteStart = """"
DTE.UndoContext.Open("SQL 2 CSharp")
Try
startPoint.Insert("string sql = """)
Do While (True)
Dim line As Integer
line = startPoint.Line
startPoint.Insert(quoteStart)
startPoint.EndOfLine()
If (line = endPoint.Line) Then
startPoint.Insert(quoteStart & ";")
Else
startPoint.Insert(quoteStart & "+")
End If
startPoint.LineDown()
startPoint.StartOfLine()
If (line = endPoint.Line) Then
Exit Do
End If
Loop
Finally
' If an error occurred, then make sure that the undo context is cleaned up.
' Otherwise, the editor can be left in a perpetual undo context.
DTE.UndoContext.Close()
End Try
End Sub
You can never try. You either do it or you don't.
|
|
|
|
|
Why would anyone need or want this? You SHOULD NOT be using inline SQL at all.
only two letters away from being an asset
|
|
|
|
|
Are you suggesting I should use the alternatives for SQL like SPs, functions, views etc?
You can never try. You either do it or you don't.
|
|
|
|
|
Only if you want your applications to perform better, be more maintainable and more secure
only two letters away from being an asset
|
|
|
|
|
And why the hell would we want that?!
|
|
|
|
|
Why would this be insecure if there is no WHERE clause associated with the SQL statement?
Depending on if it is a reusable/non-reusable SQL statement, I think its a personal preference to keep the SQL in code or move it to database.
You can never try. You either do it or you don't.
|
|
|
|
|
If you have to ask it shows you really have no idea what your doing. Help make this profession better, drop out now.
only two letters away from being an asset
|
|
|
|
|
I never would've thought this kind of comment would come from a CodeProject supporter. I'm just thinking about this kind of response in general is what makes a good or bad forum.
Now, if you can please answer the question (which was a genuine one), everyone who reads this thread now and a few years from now will learn something.
You can never try. You either do it or you don't.
|
|
|
|
|
|
Mark,
We are going on a tangent here.
I understand the questions in the threads you posted are coming from novice programmers, they posted in an entirely irrelevent forum, and that they didn't do their homework. People do that all the time, every minute, every hour, every day.
I see no relation to the question on hand.
You can never try. You either do it or you don't.
|
|
|
|
|
No, you should be using LINQ, but short of that, there is nothing wrong with parametrised inline SQL.
|
|
|
|
|
A hearty debate but the general consensus is to use stored procs for a number of benefits.
only two letters away from being an asset
|
|
|
|