Wednesday, March 7, 2012

CLR access to File Info

"KurtK" <KurtK@.discussions.microsoft.com> wrote in message
news:D85635C4-9444-4CD4-8323-1903F8EA9B58@.microsoft.com...
> testFile = My.Computer.FileSystem.GetFileInfo(Filename)
VB My.* code is not supported under SQLCLR. If you used a VS Sql Server
Project you'll notice that you can't compile and deploy it from there as the
My feature is not supported for this project type:
http://msdn2.microsoft.com/en-us/library/ms172698.aspx
Changing your code to
testFile = new FileInfo(Filename)
should work
StevenSteven,
I tried replacing
testFile = My.Computer.FileSystem.GetFileInfo(Filename)
with
testFile = FileIO.FileSystem.GetFileInfo(Filename)
which seemed to be the only way to get to the GetFileInfo method. However I
still get the same exception.
This is my first venture into Visual Studio/.net since we still develop
under VB6 so I'm using the command line to compile my .vb code as was shown
in an example CLR integration sample I found.
Thanks,
Kurt
"Steven Hemingray [MSFT]" wrote:

> "KurtK" <KurtK@.discussions.microsoft.com> wrote in message
> news:D85635C4-9444-4CD4-8323-1903F8EA9B58@.microsoft.com...
> VB My.* code is not supported under SQLCLR. If you used a VS Sql Server
> Project you'll notice that you can't compile and deploy it from there as t
he
> My feature is not supported for this project type:
> http://msdn2.microsoft.com/en-us/library/ms172698.aspx
> Changing your code to
> testFile = new FileInfo(Filename)
> should work
> Steven
>
>|||I got it to work if I set the permission to UNSAFE. However since I'm only
accessing the FileInfo class it seems like EXTERNAL should be good enough.
What gives'
-Kurt
"Steven Hemingray [MSFT]" wrote:

> "KurtK" <KurtK@.discussions.microsoft.com> wrote in message
> news:D85635C4-9444-4CD4-8323-1903F8EA9B58@.microsoft.com...
> VB My.* code is not supported under SQLCLR. If you used a VS Sql Server
> Project you'll notice that you can't compile and deploy it from there as t
he
> My feature is not supported for this project type:
> http://msdn2.microsoft.com/en-us/library/ms172698.aspx
> Changing your code to
> testFile = new FileInfo(Filename)
> should work
> Steven
>
>|||My.Computer.FileSystem is very similar to FileIO.FileSystem so neither
approach works under SQLCLR.
However, I checked that using 'testFile = new System.IO.FileInfo(Filename)'
does work - is there a specific reason you need to use GetFileInfo?
Steven
"KurtK" <KurtK@.discussions.microsoft.com> wrote in message
news:A5EEEC2D-A66A-46DC-BCC2-70978AD47508@.microsoft.com...
> Steven,
> I tried replacing
> testFile = My.Computer.FileSystem.GetFileInfo(Filename)
> with
> testFile = FileIO.FileSystem.GetFileInfo(Filename)
> which seemed to be the only way to get to the GetFileInfo method. However
> I
> still get the same exception.
> This is my first venture into Visual Studio/.net since we still develop
> under VB6 so I'm using the command line to compile my .vb code as was
> shown
> in an example CLR integration sample I found.
> Thanks,
> Kurt
>
> "Steven Hemingray [MSFT]" wrote:
>|||Thanks. That works with permission set to EXTERNAL. And to answer your
question, I don't have to use GetFileInfo if there is another way to test fo
r
a file's existence.
Thanks for your help.
-Kurt
"Steven Hemingray [MSFT]" wrote:

> My.Computer.FileSystem is very similar to FileIO.FileSystem so neither
> approach works under SQLCLR.
> However, I checked that using 'testFile = new System.IO.FileInfo(Filename)
'
> does work - is there a specific reason you need to use GetFileInfo?
> Steven
> "KurtK" <KurtK@.discussions.microsoft.com> wrote in message
> news:A5EEEC2D-A66A-46DC-BCC2-70978AD47508@.microsoft.com...
>
>|||"examnotes" <KurtK@.discussions.microsoft.com> wrote in
news:16E92B69-081D-415E-B168-1F2494ED0D2C@.microsoft.com:

> , I don't have to use GetFileInfo if there is another way to test for
> a file's existence.
>
System.IO.File.Exists(path)
Niels
****************************************
**********
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb@.no-spam.develop.com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
****************************************
**********

No comments:

Post a Comment