473,776 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I convert a FileInfo.Attrib utes to a SqlDBType

I'm trying write a SQLCLR that returns FileInfo.Attrib utes property to SQL
Server in a record set and I am getting the following error.

cannot convert from 'System.IO.File Attributes' to
'System.Data.Sq lTypes.SqlInt32 '

How can I convert the Attributes to display an integer value. Clearly the
code below doesn't work. What do I need to do to make it work?

FileInfo f = new FileInfo(FileIn fo);
SqlMetaData Attributes;
Attributes = new SqlMetaData("At tributes", SqlDbType.Int);
record = new SqlDataRecord(n ew SqlMetaData[] { Attributes });
record.SetSqlIn t32(0,f.Attribu tes);
May 31 '06 #1
2 2028
Greg,

You can just cast the enumeration value, like so:

record.SetSqlIn t32(0, (int) f.Attributes);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Greg Larsen" <Gr********@dis cussions.micros oft.com> wrote in message
news:EC******** *************** ***********@mic rosoft.com...
I'm trying write a SQLCLR that returns FileInfo.Attrib utes property to SQL
Server in a record set and I am getting the following error.

cannot convert from 'System.IO.File Attributes' to
'System.Data.Sq lTypes.SqlInt32 '

How can I convert the Attributes to display an integer value. Clearly the
code below doesn't work. What do I need to do to make it work?

FileInfo f = new FileInfo(FileIn fo);
SqlMetaData Attributes;
Attributes = new SqlMetaData("At tributes", SqlDbType.Int);
record = new SqlDataRecord(n ew SqlMetaData[] { Attributes });
record.SetSqlIn t32(0,f.Attribu tes);

Jun 1 '06 #2
That worked great. Thanks.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Greg,

You can just cast the enumeration value, like so:

record.SetSqlIn t32(0, (int) f.Attributes);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Greg Larsen" <Gr********@dis cussions.micros oft.com> wrote in message
news:EC******** *************** ***********@mic rosoft.com...
I'm trying write a SQLCLR that returns FileInfo.Attrib utes property to SQL
Server in a record set and I am getting the following error.

cannot convert from 'System.IO.File Attributes' to
'System.Data.Sq lTypes.SqlInt32 '

How can I convert the Attributes to display an integer value. Clearly the
code below doesn't work. What do I need to do to make it work?

FileInfo f = new FileInfo(FileIn fo);
SqlMetaData Attributes;
Attributes = new SqlMetaData("At tributes", SqlDbType.Int);
record = new SqlDataRecord(n ew SqlMetaData[] { Attributes });
record.SetSqlIn t32(0,f.Attribu tes);


Jun 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6012
by: G. Richard Bellamy | last post by:
I'm trying to unset the Encrypted attribute on all the files in a path. The attribute is not getting set. What am I doing wrong? Perhaps there's another newsgroup I can send this to? Here's the code: ============================================= using System;
7
12260
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for these file attributes.
1
1801
by: Benjamin | last post by:
I am trying to make a file I created a hidden file. I think I need to use the setfileattribute() but I cannot find it anywhere. I found this on msdn: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcedata5/html/wce50lrfsetfileattributes.asp can anyone direct me in the right direction?
4
409
by: G. Richard Bellamy | last post by:
I'm trying to unset the Encrypted attribute on all the files in a path. The attribute is not getting set. What am I doing wrong? Perhaps there's another newsgroup I can send this to? Here's the code: ============================================= using System;
0
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10289
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8952
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.