Showing posts with label dir. Show all posts
Showing posts with label dir. Show all posts

Wednesday, March 28, 2012

System.IO: best approach for clearing a DIR of all files except .CSV

hiya,
I have a DIR that should only accept .CSV files..I haven't found a way to
do this prorgramatically.

ATM, I:
1) obtain an array of all the files that contain a .CSV extension.
2) move these files to another dir.

I check to see if there are any NON-CSV files in the dir by the following:

<code>
If arrAllFiles.Length = arrCsvFiles.Length Then
'do nothing, as this DIR only contained CSV files.
Else
'delete ALL the files in this dir, as the CSV files have already been
moved.
'The remaining files are therefore, NON-CSV
End If
<\code
Is this a good approach?Or maybe there is a slicker way to achieve what I
am trying to do / maybe there are some utilities out there that already do
all the system.IO stuff?

All thoughts appreciated.

many thanks
yogi

--
Message posted via http://www.dotnetmonster.comYou could also loop through all the files, checkif they EndsWith(".csv") if
not, delete them.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)

"chris yoker via DotNetMonster.com" <forum@.nospam.DotNetMonster.com> wrote
in message news:86e839cf6238492484f4c941524b48a4@.DotNetMonste r.com...
> hiya,
> I have a DIR that should only accept .CSV files..I haven't found a way to
> do this prorgramatically.
> ATM, I:
> 1) obtain an array of all the files that contain a .CSV extension.
> 2) move these files to another dir.
> I check to see if there are any NON-CSV files in the dir by the following:
> <code>
> If arrAllFiles.Length = arrCsvFiles.Length Then
> 'do nothing, as this DIR only contained CSV files.
> Else
> 'delete ALL the files in this dir, as the CSV files have already been
> moved.
> 'The remaining files are therefore, NON-CSV
> End If
> <\code>
> Is this a good approach?Or maybe there is a slicker way to achieve what I
> am trying to do / maybe there are some utilities out there that already do
> all the system.IO stuff?
> All thoughts appreciated.
> many thanks
> yogi
> --
> Message posted via http://www.dotnetmonster.com

System.IO: best approach for clearing a DIR of all files except .CSV

hiya,
I have a DIR that should only accept .CSV files..I haven't found a way to
do this prorgramatically.
ATM, I:
1) obtain an array of all the files that contain a .CSV extension.
2) move these files to another dir.
I check to see if there are any NON-CSV files in the dir by the following:
<code>
If arrAllFiles.Length = arrCsvFiles.Length Then
'do nothing, as this DIR only contained CSV files.
Else
'delete ALL the files in this dir, as the CSV files have already been
moved.
'The remaining files are therefore, NON-CSV
End If
<\code>
Is this a good approach?Or maybe there is a slicker way to achieve what I
am trying to do / maybe there are some utilities out there that already do
all the system.IO stuff?
All thoughts appreciated.
many thanks
yogi
Message posted via http://www.webservertalk.comYou could also loop through all the files, checkif they EndsWith(".csv") if
not, delete them.
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"chris yoker via webservertalk.com" <forum@.nospam.webservertalk.com> wrote
in message news:86e839cf6238492484f4c941524b48a4@.Do
webservertalk.com...
> hiya,
> I have a DIR that should only accept .CSV files..I haven't found a way to
> do this prorgramatically.
> ATM, I:
> 1) obtain an array of all the files that contain a .CSV extension.
> 2) move these files to another dir.
> I check to see if there are any NON-CSV files in the dir by the following:
> <code>
> If arrAllFiles.Length = arrCsvFiles.Length Then
> 'do nothing, as this DIR only contained CSV files.
> Else
> 'delete ALL the files in this dir, as the CSV files have already been
> moved.
> 'The remaining files are therefore, NON-CSV
> End If
> <\code>
> Is this a good approach?Or maybe there is a slicker way to achieve what I
> am trying to do / maybe there are some utilities out there that already do
> all the system.IO stuff?
> All thoughts appreciated.
> many thanks
> yogi
> --
> Message posted via http://www.webservertalk.com

Monday, March 26, 2012

System.Net.Mail SMTP Pickup Dir

Hi,

I am trying to write .eml files to a remote UNC directory - do you
know if this could be done, such as:

<mailSettings>
<smtp>
<network

host="localhost"
port="25"
/
<specifiedPickupDirectory pickupDirectoryLocation="\\server1\Pickup"/>
</smtp>
</mailSettings
If so, would I have to change the defaultCredentials or the security
context for ASP.NET (using machine.config)? I haven't exactly done
that before.

Thank you,
MichaelFYI: I found the answer in case anyone wonders about this. Make sure
the AppPool for the IIS web site is running as IWAM_machinename and
that the \Pickup windows share allows IWAM_machinename (using same
username/password on remote machine) write access in addition to the
NTFS write for that subdirectory is allowed.

mpaine@.htxml.com wrote:

Quote:

Originally Posted by

Hi,
>
>
I am trying to write .eml files to a remote UNC directory - do you
know if this could be done, such as:
>
<mailSettings>
<smtp>
<network
>
host="localhost"
port="25"
/>
>
<specifiedPickupDirectory pickupDirectoryLocation="\\server1\Pickup"/>
</smtp>
</mailSettings>
>
If so, would I have to change the defaultCredentials or the security
context for ASP.NET (using machine.config)? I haven't exactly done
that before.
>
>
Thank you,
Michael