473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

File.SetAttributes problem

Hi All,
I've modified a simple Aspnet program from a text to show file information,
including attributes and I keep getting an error which I cannot seem to
solve; here's the important parts:
Imports System
Imports System.IO
Imports System.IO.DirectoryInfo
Imports System.IO.File
Imports System.IO.FileAttributes
............
Private Sub PageLoad()
Dim f as new FileInfo("file path")............
'change file attributes to hidden or archive just for kix
'File.SetAttributes(path, FileAttributes.Archive)
'File.SetAttributes(path, FileAttributes.Hidden)
'f.Attributes = 2
'f.Attributes = FileAttributes.Hidden
'none of these work,
The program compiles fine, but kicks out on run with this error:
System.ArgumentException: Invalid File or Directory attributes value. When
the error lines above are commented out, the program runs fine. Any help is
much appreciated.
BruceL
Feb 28 '06 #1
1 2412
DWS
Bruce,
First off you need an existing file path
I'm pointing f to app_data/lawsonfiles (you create this folder)

Dim f as new FileInfo(server.mappath("~/app_data/Lawsonfiles/"))

Good Luck
DWS


"Bruce Lawson" wrote:
Hi All,
I've modified a simple Aspnet program from a text to show file information,
including attributes and I keep getting an error which I cannot seem to
solve; here's the important parts:
Imports System
Imports System.IO
Imports System.IO.DirectoryInfo
Imports System.IO.File
Imports System.IO.FileAttributes
............
Private Sub PageLoad()
Dim f as new FileInfo("file path")............
'change file attributes to hidden or archive just for kix
'File.SetAttributes(path, FileAttributes.Archive)
'File.SetAttributes(path, FileAttributes.Hidden)
'f.Attributes = 2
'f.Attributes = FileAttributes.Hidden
'none of these work,
The program compiles fine, but kicks out on run with this error:
System.ArgumentException: Invalid File or Directory attributes value. When
the error lines above are commented out, the program runs fine. Any help is
much appreciated.
BruceL

Mar 1 '06 #2

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

Similar topics

2
by: Tony Hedge | last post by:
Hello, 1.1 .NET running on Windows XP... I have read only files on my local machine. I want to use the above SetAttributes to check OFF the readonly attribute for some of those files because...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
7
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...
0
by: Next | last post by:
Hello, I am trying to uncheck the archive box and check the compress box for a given file. I am having trouble. It seems I can uncheck the archive box but nothing I've tried will check the...
1
by: John Grandy | last post by:
How to remove "Read Only" status on a file on a remote server? My goal is to delete the file, but System.File.Delete(\\machine1\c$\folder1\file1.txt) is giving me an "Access is denied"...
1
by: Blue Man | last post by:
Anybody has idea how to save value in web.config file during runtime? ConfigurationSettings.AppSettings.Add("test","test value"); won't work, it will cause and error : the file is read only...
4
by: Debbie Carter | last post by:
Would anyone know how to read the file attributes of a file on the hard drive to check if the file is encrypted or not? I have searched Visual Studio Help and MSDN and the samples I have found do...
6
by: =?Utf-8?B?V2F5bmUgR29yZQ==?= | last post by:
Hi I want to achive 2 things. First I would like to compress an existing file on my harddrive. I can easily find out if a file is compressed or not by using "File.GetAttributes". But no matter...
1
by: rcook349 | last post by:
From within my project, I am opening an file elsewhere on the network and changing contents within. When I go to close/save, however, I can't because it's read-only (as it's checked in). Can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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,...

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.