易截截图软件、单文件、免安装、纯绿色、仅160KB

VS2005中,access对只读目录的属性判断不准确

只读目录,
C:\>attrib +A +S +H +R testdir
C:\>attrib testdir
A  SHR     C:\testdir
(1)VC6.0的执行结果:
***********test stat***********************
file [c:\testdir] exists!
file [c:\testdir] is directory!
file [c:\testdir] can be read!
file [c:\testdir] can not be writed!
***********test access***********************
file [c:\testdir] exists!
file [c:\testdir] can not be writed!
file [c:\testdir] can be read!
(2)VS2005的执行结果
***********test stat***********************
file [c:\testdir] exists!
file [c:\testdir] is directory!
file [c:\testdir] can be read!
file [c:\testdir] can not be writed!
***********test access***********************
file [c:\testdir] exists!
file [c:\testdir] can be writed!
file [c:\testdir] can be read!
结论:在VS2005中,使用access判断的只读目录却有【写入】的属性。
         有什么高招,欢迎解答。
建议,在VS2005中对文件、目录进行权限校验时,最好不要用access。
#include <stdio.h>
#include <windows.h>
#include <stdio.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
int main(int argc ,char *argv[])
{
struct stat buf;
int ret = 0;
int i=0;

char *file = "c:\\testdir";

printf("***********test stat***********************\n");
ret = stat(file, &buf );
if(ret != 0)
{
printf("stat [%s] fail, errno=%d\n", file, errno);
return -1;
}
else
printf("file [%s] exists!\n", file);

if((buf.st_mode&S_IFDIR)==0)
printf("file [%s] is not directory!\n", file);
else
printf("file [%s] is directory!\n", file);

if((buf.st_mode&S_IREAD)!=0)
printf("file [%s] can be read!\n", file);
else
printf("file [%s] can not be read!\n", file);

if((buf.st_mode&S_IWRITE)!=0)
printf("file [%s] can be writed!\n", file);
else
printf("file [%s


相关文档:

利用 DataGridView 绘制图片列表(从Access读取图片)

using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using Microsoft.Win32;
using Access = Microsoft.Office.Interop.Access;
namespace ImageAccess
{
    static class Program
    {
   ......

Android: Requesting root access in your app

转帖:http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/
This snippet shows how root access can be requested inside an application in order to write a file into a place we do not have permission to access usually. Requesting root access will only work if your phon ......

asp连接access数据例子

<%Dim connstrconnstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Stu.mdb")
Set bb = Server.CreateObject("ADODB.Connection")
bb.Open connstr%>
<html>
<head>
<meta http-equiv="content-Language" content="zh-cn" />
<meta http-equiv="Content-Type ......

将access导入SQL server (转)

熟悉SQL SERVER 2000的数据库管理员都知道,其DTS可以进行数据的导入导出,其实,我们也可以使用Transact-SQL语句进行导入导出操作。在 Transact-SQL语句中,我们主要使用OpenDataSource函数、OPENROWSET 函数,关于函数的详细说明,请参考SQL联机帮助。利用下述方法,可以十分容易地实现SQL SERV ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号