Net1.1没有专门封装好的WIN32管理类(2.0就方便多了),分享一下目录共享及权限的方法(网上找了许多都是文不对题的)



权限定义:
[Flags]
   public enum AccessPrivileges : uint{
   FILE_READ_DATA = 0x00000001,
   FILE_WRITE_DATA = 0x00000002,
   FILE_APPEND_DATA = 0x00000004,
   FILE_READ_EA = 0x00000008,
   FILE_WRITE_EA = 0x00000010,
   FILE_EXECUTE = 0x00000020,
   FILE_DELETE_CHILD = 0x00000040,
   FILE_READ_ATTRIBUTES = 0x00000080,
   FILE_WRITE_ATTRIBUTES  = 0x00000100,

   DELETE = 0x00010000,
   READ_CONTROL = 0x00020000,
   WRITE_DAC = 0x00040000,
   WRITE_OWNER = 0x00080000,
   SYNCHRONIZE = 0x00100000,

   ACCESS_SYSTEM_SECURITY = 0x01000000,
   MAXIMUM_ALLOWED = 0x02000000,
   
   GENERIC_ALL = 0x10000000,
   GENERIC_EXECUTE= 0x20000000,
   GENERIC_WRITE = 0x40000000,
   GENERIC_READ = 0x80000000
  }


  [Flags]
   enum AceFlags : uint{
   NonInheritAce = 0,
   ObjectInheritAce = 1,
   ContainerInheritAce = 2,
   NoPropagateInheritAce = 4,
   InheritOnlyAce = 8,
   InheritedAce = 16
  }

  [Flags]
   enum AceType : uint{
   AccessAllowed = 0,
   AccessDenied = 1,
   Audit = 2
  }


流程:

//设置Everyone用户,可以选择其他用户或新建用户
   ManagementClass trustee = new ManagementClass("Win32_Trustee");
   trustee.Properties["Name"].Value = "Everyone";
   trustee.Properties["Domain"].Value = null;
   trustee.Properties["SID"].Value = new byte[]{1,1,0,0,0,0,0,1,0,0,0,0};

//设置只读/运行权限
   ManagementClass ace = new ManagementClass("Win32_ACE");
   ace.Properties["AccessMask"].Value = AccessPrivileges.GENERIC_READ
    | AccessPrivileges.FILE_READ_DATA | AccessPrivileges.FILE_READ_ATTRIBUTES | AccessPrivileges.FILE_READ_EA
    | AccessPrivileges.READ_CONTROL | AccessPrivileges.FILE_EXECUTE;
   ace.Properties["AceFlags"].Value = 3;//AceFlags.ObjectInheritAce | AceFlags.ContainerInheritAce ;
   ace.Properties["AceType"].Value = 0;//AceType.AccessAllowed;
   ace.Properties["Trustee"].Value = trustee;

//修改ACL设置
   ManagementObject secDescriptor = new ManagementClass("Win32_SecurityDescriptor");
   secDescriptor["ControlFlags"] = 4;
   secDescriptor["DACL"] = new ManagementObject[] { ace };


   //设置添加共享
   ManagementClass mc = new ManagementClass("win32_share");
   ManagementBaseObject inParams = mc.GetMethodParameters("Create");
   inParams["Path"] = "f:\\dannyr";
   inParams["Name"] = "share of dannyr";
   inParams["Type"] = 0x0;
   inParams["MaximumAllowed"] = null;      //=null 则用户数连接无限制
   inParams["Description"] = null;
   inParams["Password"] = null;
   inParams["Access"] = secDescriptor;  //=null 则使Everyone拥有完全控制权限

   ManagementBaseObject outParams = mc.InvokeMethod("Create", inParams, null);
   uint returnValue = (uint)outParams.Properties["ReturnValue"].Value;
   string ErrorMessage = null;
   switch (returnValue)
   {
    case 0: //Success
     break;
    case 2: //Access denied
     ErrorMessage = "无权访问";
     break;
    case 8: //Unknown failure
     ErrorMessage = "未知错误";
     break;
    case 9: //Invalid name
     ErrorMessage = "非法的共享名";
     break;
    case 10: //Invalid level
     ErrorMessage = "非法的层次";
     break;
    case 21: //Invalid parameter
     ErrorMessage = "非法的参数";
     break;
    case 22: //Duplicate share
     ErrorMessage = "重复共享";
     break;
    case 23: //Redirected path
     ErrorMessage = "重定向路径";
     break;
    case 24: //Unknown device or directory
     ErrorMessage = "未知的目录";
     break;
    case 25: //Net name not found
     ErrorMessage = "网络名不存在";
     break;
    default:
     break;
   }

posted @ 2008-06-20 17:03 dannyr|一个都不能少! 阅读(1440) | 评论 (1)编辑
Access数据库对于文本和备注类型的数据类型定义(DATA_TYPE)都是为130,无法直接区分,找了N多网页,包括MSDN都没有描述有关COLUMN_FLAGS的说明,还是自己分析一下:

    COLUMN_FLAGS为64位(8字节)的十六进制的值,组合了数据类型和必填字段等信息

其中最后2个字节有效,最后一个字节一直为0x0A,有变化的是最后第二个字节,即:
    对于文本类型的为0x00;备注类型为0x80;
    对于非必填字段为0x40;必填字段为0x60

组合后:
   文本必填:  0x6A
   文本非必填:0x4A
   备注必填:  0xEA
   备注非必填:0xCA
   
最后可以得到COLUMN_FLAGS右移7位后可以区分文本类型和备注类型


DataTable dt = m_OLEDBCon.GetOleDbSchemaTable(
    OleDbSchemaGuid.Columns,
    new object[] {null, null, "表名称", null});

DataRow[] drs = dt.Select("COLUMN_NAME='字段名称'");
if(drs.Length > 0 && Convert.ToInt32(drs[0]["DATA_TYPE"]) == 130) {
    //文本类型
    if ( (Convert.ToInt64(drs[0]["COLUMN_FLAGS"]) >> 7) == 1){
        //=1为备注字段       
    }else{
        //=0为文本字段
    }
}
posted @ 2008-05-22 10:10 dannyr|一个都不能少! 阅读(1747) | 评论 (4)编辑

灰色
posted @ 2008-05-19 09:34 dannyr|一个都不能少! 阅读(111) | 评论 (0)编辑
下面的代码是可以执行,大家都来说说为什么这个程序不会自动退出?
也就是说mian函数执行完毕后,为什么.net不会释放ThreadEx对象?

using System;
using System.Threading;

public class ThreadEx : IDisposable{    
    
private Thread thread;
    
private volatile bool bExit;
    
public ThreadEx(){
        Console.WriteLine(
"ThreadEx output");
        bExit 
= false;
        thread 
= new Thread(OnThread);
        thread.Start();
    }


    
~ThreadEx(){
        Console.WriteLine(
"~ThreadEx output");
        bExit 
= true;
    }


    
private void OnThread(){
        
while(true){
            
if(bExit){
                
break;
            }

            Console.WriteLine(
"Thread output");
            Thread.Sleep(
1000);
        }

        Console.WriteLine(
"Thread exit");
    }


    
private void Close(){
        bExit 
= true;
    }


    
public void Dispose() {
        
// TODO:  添加 ThreadEx.Dispose 实现
        Console.WriteLine("~Dispose output");
        bExit 
= true;
    }


    
static void Main(){
        ThreadEx threadEx 
= new ThreadEx();
    }

}
posted @ 2007-09-28 16:42 dannyr|一个都不能少! 阅读(2232) | 评论 (16)编辑
As is known,in many advanced programming languages(esp. object oriented ones) like c/c++,c#,Java,etc., the function is only one of the programming syntax constructs,unlike that in some pure interpreted programming lanuage such as Javascript,SmallTalk and so on,which are also object oriented,the function itself is a first-class object,however,for example:
 
function Foo() { // note: Foo is an object
    this.sampleMemVar = 123;
    
this.sampleMemFun = function() {}; // create a new function object
    function() {}; // anonymouse function object
    var f = function(){}; // equal to function f() {} declaration,also create new function object
};

 
As a result,foo can behaves in the same way as regular object do,that is to say,foo can have properties,member functions,and can be extended,see below:
 

Foo.prototype.sampleVar 
= 0;
Foo.prototype.sampleFun 
= function(arglist) {}; // prototype is one of the properties of object Foo
Foo.sampleStaticVar = "sample static variable"// static variable
Foo.sampleStaticFun = function() // extend Foo with a static function
var foo = new Foo(); // applying new operator on a function object causing an instance of an Object is created with the members declared in the constructor,i.e.,Foo.
foo.toString(); // inherited from Object
typeof(foo); // you can call typeof operator on foo,where Object is returned
typeof(Foo); // call tpyeof operator on Foo,where Function is returned
printf(Foo.sampleStaticVar);
foo.sampleMemVar 
= 100// access instance variable
Foo.sampleStaticFun(); // call static method
foo.sampleMemFun(); // call instance method

 
No need to enumerate the examples any more. You can see that the function has no much differences from general objects,except that it does inherites from Function on the other hand.
 
Then how about the situation in c/c++,or others?
For example, we have a function,which can perform some action on two operands,and the specified action can only be determined at runtime.Then how to solve this problem?
 
Of course,you can use (memebr) function pointer like:
 
typedef int (*OpFunc)(int left,int right);


 
but you should first know the argument types and return type.
how about template?
 
template<class _Arg1,class _Arg2,class _Result>
_Result(
*OpFunc)(_Arg1 arg1,_Arg2 arg2); // this does not compile

 
You could never use template directly on typedef or object declarations.
Then maybe you want to encapsulate the concept in this way:
 
template<class _Arg1,class _Arg2,class _Result>
class Performer
{
public:
 typedef _Result (
*OpFunc)(_Arg1,_Arg2);
 Performer(OpFunc _opfunc) : m_opfunc(_opfunc)
 {
  _ASSERT(NULL 
!= _opfunc);
 }
 _Result Perform(_Arg1 arg1,_Arg2 arg2)
 {
  
return m_opfunc(arg1,arg2);
 }
private:
 OpFunc m_opfunc;
};

 
Yes,this works. However,function pointer itself is not an object oriented construct,as a result,lack of flexibility and extensibility.
 
Then,if you're familar with c#,you may want to use delegate.
And unlike template in c++,you can apply generic on delegate directly.
 

delegate _Result OpFunc<_Arg1,_Arg2,_Result>(_Arg1 arg1,_Arg2 arg2);
class Performer<_Arg1, _Arg2, _Result>
{
    
private OpFunc<_Arg1, _Arg2, _Result> opfun = null;
    
public Performer(OpFunc<_Arg1, _Arg2, _Result> _opfun)
    {
        
if (null == _opfun) throw new ArgumentException();
        
this.opfun = _opfun;
    }
    
public _Result Perform(_Arg1 arg1, _Arg2 arg2)
    {
        
return opfun(arg1, arg2);
    }
}

 
you can even implement you delegate in c++,only by making a wrapper to any function pointer.
No matter what you do with delegate,you are actually using function pointers,then again,lack of flexibility and extensibility.
 
So, why not use polymorphism?
If we can store the runtime action performer in an object,e.g.,action_performer,and we call the method on this object,where different object has different implementation for that action.
 

template
<class _Arg1,class _Arg2,class _Result>
class PerformerBase
{
public:
 
virtual _Result Perform(_Arg1 arg1,_Arg2 arg2) = 0;
};
template
<class _Arg1,class _Arg2,class _Result>
class AddPerformer : public PerformerBase<_Arg1,_Arg2,_Result>
{
public:
 _Result Perform(_Arg1 arg1,_Arg2 arg2)
 {
  
return arg1 + arg2;
 }
};
template
<class _Arg1,class _Arg2,class _Result>
class MinusPerformer : public PerformerBase<_Arg1,_Arg2,_Result>
{
public:
 _Result Perform(_Arg1 arg1,_Arg2 arg2)
 {
  
return arg1 - arg2;
 }
};

 
Yes,this also works and we can gain much flexibility and extensibility from this solution.
Then if we we can use function object as we do in Javascript,we can gain much more.
Forget operator overloading?( return to your c++ textbook for a look:-))
we can obtain a function object by encapsulate the function and overload it call operator,i.e.().
For example,
 
class Functor
{
public:
    
int operator()(int a,int b) { return a + b; }
};
Functor myFuncObj;
int x = myFuncObj(1,2);

 
Quite easy,right?
 
OK,then let's return to our problem,which is now trivial,given below:
 
template<class _Arg1,class _Arg2,class _Result>
class FunctorBase
{
public:
 
virtual _Result operator()(_Arg1 arg1,_Arg2 arg2) = 0;
};
template
<class _Arg1,class _Arg2,class _Result>
class AddFunctor : public FunctorBase<_Arg1,_Arg2,_Result>
{
public:
 _Result 
operator()(_Arg1 arg1,_Arg2 arg2)
 {
  
return arg1 + arg2;
 }
};
template
<class _Arg1,class _Arg2,class _Result>
class MinusFunctor : public FunctorBase<_Arg1,_Arg2,_Result>
{
public:
 _Result 
operator()(_Arg1 arg1,_Arg2 arg2)
 {
  
return arg1 - arg2;
 }
};
template
<class _Arg1,class _Arg2,class _Result>
class Performer
{
public:
 Performer(FunctorBase
<_Arg1,_Arg2,_Result> & functor)
  : m_functor(functor)
 {
 }
 _Result Perform(_Arg1 arg1,_Arg2 arg2)
 {
  
return m_functor(arg1,arg2);
 }
private:
 FunctorBase
<_Arg1,_Arg2,_Result> & m_functor;
};

 
In conclusion, you can implement your own specific function object(functor) even in c++,c#,etc.,then you can use function as general objects in your program with high flexibility,resuability and extensibility. Actually, if you look into the STL,you will find that many functions receive a functor as a parameter,e.g.,find_if in <algorithm> receives a predictor as a searching criteria. see declaration below:
 
template<class InputIterator, class Predicate>
   InputIterator find_if(
      InputIterator _First,
      InputIterator _Last,
      Predicate _Pred
   );

 
then you can call like this:
int arr[] = {1,2,3,4,5};
int * found = find_if(arr,arr + _countof(arr),greater<int>(2)); // find element that is greater thatn 2.
 

functors are declared in <functional> in STL.

posted @ 2007-09-15 08:03 dannyr|一个都不能少! 阅读(195) | 评论 (0)编辑
//GridView属性设置:
GridView.OptionsView.GroupDrawMode = GroupDrawMode.Office2003;
GridView.OptionsView.ShowVertLines 
= true;

//GridColumn分组列属性设置:
GridColumn.GroupIndex = 0;
GridColumn.GroupInterval 
= ColumnGroupInterval.DateRange;

//GridControl数据绑定后,设置GridView
gvReserve.SetRowExpanded(-1true);
gvReserve.SetRowExpanded(
-2true);

a.JPG
posted @ 2007-08-06 13:27 dannyr|一个都不能少! 阅读(781) | 评论 (5)编辑
   frm.MdiParent = this;
   
//frm.WindowState = FormWindowState.Maximized;
   frm.Dock = DockStyle.Fill;   //设置为ChildForm和MainForm一起拉伸
   frm.FormBorderStyle = FormBorderStyle.None;
   
this.Client_Event += new Message_Event(frm.OnClientEvent);
   frm.m_Operator 
= m_Operator;
   
return frm;
posted @ 2007-07-27 15:06 dannyr|一个都不能少! 阅读(455) | 评论 (0)编辑
DevExpress.XtraEditors.ComboBoxEdit
下拉框是否允许输入
Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor
posted @ 2007-07-24 11:43 dannyr|一个都不能少! 阅读(190) | 评论 (0)编辑
var firefox = document.getElementById && !document.all;


IE浏览器和FireFox浏览器都有getElementById方法,而FireFox没有document.all方法,因此当上面firefox变量为false说明为IE浏览器。
posted @ 2007-07-06 11:22 dannyr|一个都不能少! 阅读(454) | 评论 (0)编辑
posted @ 2007-01-17 16:10 dannyr|一个都不能少! 阅读(558) | 评论 (1)编辑

下载:

http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_spry

 

Changes for Spry PreRelease 1.4 - 2006/12/14

  • Data
    • Added function Spry.Utils.serializeObject() for serializing a JS Object into JSON format.
    • Added Spry.XML.nodeToObject() and Spry.XML.documentToObject() utility methods which allow developers to access XML data as JS properties on an object in a manner which is similar to E4X.
    • Added Spry.Utils.updateContent() for dynamically loading an HTML fragment into an element.
    • Added Spry.Utils.setInnerHTML() for setting the innerHTML of an element and executing any scripts within the content string. This method is now used by Spry regions when regenerating their content.
    • Added support for mapping a region state name to another state name. This can be useful for overriding the built-in states, like "ready", "loading", and "error", so that they use markup from a custom state when they fire.
    • Added support for more attributes:
      • spry:even - Conditionally adds the user specified CSS class name to an element based on the current row number used at the time that element was re-generated.
      • spry:odd - Conditionally adds the user specified CSS class name to an element based on the current row number used at the time that element was re-generated.
      • spry:setrow - Attaches a non-destructive onclick handler that sets the current row by row ID.
      • spry:setrownumber - Attaches a non-destructive onclick handler that sets the current row by row number.
      • spry:sort - Attaches a non-destructive onclick handler that sorts a specific data set based on columns specified by the user.
      • spry:readystate - Maps the "ready" state name to the name specified in its value.
      • spry:errorstate - Maps the "error" state name to the name specified in its value.
      • spry:loadingstate - Maps the "loading" state name to the name specified in its value.
    • Added code to report and error when nested regions and detail regions are detected.
    • Added new methods to the DataSet API:
      • getRowCount()
      • getRowByID()
      • getRowByRowNumber()
      • findRowsWithColumnValues()
  • Effects
    • Minor updates of documentation (effects_api and effects_coding, especially of the allowed elements to which the effects can be applied to).
    • Fixed bugs:
      • GrowShrink effect: if border is set, width&height style doesn't get reset to the original value after you toggled the target element
      • GrowShrink effect: text size inside the target element is alternated after the effect has been finished
      • Slide and Blind effect: Scrollbar disappears if overflow:scroll is set and you toggle the element
      • GrowShrink effect: nested image elements doesn't grow if you grow the target element
      • Slide effect: Text inside sliding element doesn't appear once you toggle the effect (IE 7 only)
      • Shake effect: doesn't work perperly in Opera 9.0
      • AppearFade effect: not working for content of a <div> inside a <td> (IE only)
    • new feature:
      • GrowShrink effect: added options 'referHeight' and 'growCenter'
    • IE 7 related fixes also take effect on Windows Vista (not only on XP)
    • new feature:
      • Slide effect: added option 'horizontal' to allow horizontal sliding
    • Slightly updated documentation to reflect new slide option
    • Simplified cluster construction: cluster now is an effect, too, which accepts setup and finish callbacks as option arguments of its constructor
    • Base effects (like Move, Size, etc.) can be called without from argument. Instead of passing element, fromPos, toPos, options as arguments, the effects can be called with element, toPos, options. The fromPos is calculated on the fly based on the current position.
    • AppearFade, Blind, GrowShrink, Slide and Squish effects now can be triggered for initially invisible elements ('display:none' or 'visibility:hidden')
  • Widgets
    • Added Menu Bar widget
    • Added Tabbed Panels widget
    • Added Collapsible Panel widget
    • Added Form Validation Widgets
    • Accordion:
      • Added support for variable height panels.
      • Added some new constructor options:
        • useFixedHeightPanels - This value is true by default. If false allows for variable height panels.
        • fixedPanelHeight - Number of pixels to use as the height of each panel when animating. By default this is the same as the first open panel.
        • duration - Number of milliseconds it takes to open/close a panel. Default is 500 msecs.
      • Fixed bug that prevented panels from animating properly when the accordion started out with a display:none style.
      • Removed addNewPanel(), getNewPanelSnippet(), getNewAccordionSnippet(), and getNewAccordionConstructorSnippet() methods. They don't work cross-browser, and should've never seen the light of day.
  • Docs
    • Added overview for Tabbed Panels widget.
    • Added overview for Collapsible Panel widget.
    • Added overview docs for each Form widget.
  • Demos
    • Gallery
      • Switch from using an interval timer to manually firing off the slide show timer after each image loads. This will allow images loading over slow connections to completely load.
    • Products
      • index.html to use spry:sort and spry:setrow.
      • Use a spry:choose attribute to show/preserve the currently selected product on initial load and after a sort.
    • RSS Reader
      • Modified index.{html,cfm,php} to use spry:setrow.
    • Added Form Validation demo.
  • Samples
    • Added sample for Tabbed Panels widget.
    • Added sample for Collapsible Panel widget.
    • Added samples for 4 Form widgets.
    • Moved data set and region examples to the samples/data_region folder.
    • Changed Effects sample files to use standard samples.css file.
    • Added a samples/utils folder with samples of Spry utility functions.
    • Released a query-to-XML sample page that shows how to convert dynamic data into XML.
    • Added to EvenOddRowSample.html to include spry:even and spry:odd.
    • Added SprySetRowSample.html.
    • Modified the AccordionSample:
      • Added sample for changing the duration of animations.
      • Modified variable height accordion sample to use animation.
      • Added a style for spans used as content panels so that they animate properly.
    • Added SetCurrentRowByValueSample.html to show how to select a row based on some column values.
    • Added StateMappingSample.html to show how to map the built-in region states to your own custom states.
posted @ 2006-12-20 09:48 dannyr|一个都不能少! 阅读(480) | 评论 (0)编辑

效果演示:
http://dannyr.nbdown.net/spry/index.html

代码下载:
http://dannyr.nbdown.net/filtrate.zip

说明:
代码是从Spain的MMUG拉下来的,MMUG上的是用Spry1.0,我按Spry1.3版本稍微做了修改。效果还不错,遗憾的是我的测试机上IE7和FireFox2的淡入淡出效果不一致,IE7的效果要好!同时由于动态显示数据集的区域(Region)内容是js动态生成的,在DataSet执行数据过滤后又重新填充并生成显示表,这样原先没过滤前显示区域的style效果就都丢失了,每次生成显示区域后区域里的style都是按默认值重新生成,所以每次过滤后显示区域的style效果都重置一次,没有连续性,很不如人意。

posted @ 2006-12-08 11:10 dannyr|一个都不能少! 阅读(1892) | 评论 (2)编辑
简介
        新的Flex2.0类库里提供了文件类,方便了上传/下载文件。下面的程序demo演示了Flex2.0生成flash来访问本地文件,在flash里上传用户选择的文件到服务器,flash客户端可以处理文件上传进度等多个事件,服务器端是C#写的文件接收模块,把用户上传的文件保存在服务器上。
        Demo演示了ProgressEvent.PROGRESS, Event.SELECT 2个事件的处理方法。

        顺便提一下关于JSP的接收Flex上传文件的方法(很多网友问过这个问题),我建议使用Jakarta Commons FileUpload的文件上传组件,详见:http://jakarta.apache.org/commons/fileupload/

测试效果

flexupload1.jpg


flexupload2.jpg

测试环境

操作系统:windows2003 Server
Flex版本:Flex 2.0
Flash版本: flash Player 9
WEB服务器:
          IIS 6.0
         .net FrameWork 1.1


客户端代码:FileUpload.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns
="*" creationComplete="init();">
    
<mx:Script>
        
<![CDATA[
            import flash.net.FileReference;
            import mx.controls.Alert;
            import mx.events.CloseEvent;
            import flash.events.*;

            private var file: FileReference;

            private function init(): void{
                Security.allowDomain("*");
                file = new FileReference();
                file.addEventListener(ProgressEvent.PROGRESS, onProgress);
                file.addEventListener(Event.SELECT, onSelect);
            }

            private function upload(): void{
                file.browse();
            }
            
            private function onSelect(e: Event): void{
                Alert.show("上传 " + file.name + " (共 "+Math.round(file.size)+" 字节)?",
                           "确认上传",
                           Alert.YES|Alert.NO,
                           null,
                           proceedWithUpload);
            }
            
            private function onProgress(e: ProgressEvent): void{
                lbProgress.text = " 已上传 " + e.bytesLoaded 
                    + " 字节,共 " + e.bytesTotal + " 字节";
                var proc: uint = e.bytesLoaded / e.bytesTotal * 100;
                bar.setProgress(proc, 100);
                 bar.label= "当前进度: " + " " + proc + "%";
            }
            
            private function proceedWithUpload(e: CloseEvent): void{
                if (e.detail == Alert.YES){
                    var request: URLRequest = new URLRequest("http://localhost/JZService/WebForm1.aspx");
                    try {
                        file.upload(request);
                    } catch (error:Error) {
                        trace("上传失败");
                    }
                    
                }
            }
        
]]>
    
</mx:Script>
    
    
<mx:Canvas width="100%" height="100%">
        
<mx:VBox width="100%" horizontalAlign="center">
            
<mx:Label id="lbProgress" text="上传"/>
             
<mx:ProgressBar id="bar" labelPlacement="bottom" themeColor="#F20D7A"
                minimum
="0" visible="true" maximum="100" label="当前进度: 0%"  
                direction
="right" mode="manual" width="200"/>
            
<mx:Button label="上传文件" click="upload();"/>            
        
</mx:VBox>
    
</mx:Canvas>
</mx:Application>



服务端代码:WebForm1.aspx

        private void Page_Load(object sender, EventArgs e) {
            
// 在此处放置用户代码以初始化页面
            HttpFileCollection uploadedFiles =  Request.Files;
            
string Path = Server.MapPath("data");
            
for(int i = 0 ; i < uploadedFiles.Count ; i++{
                HttpPostedFile F 
= uploadedFiles[i];
                
if(uploadedFiles[i] != null && F.ContentLength > 0{   
                    
string newName = F.FileName.Substring(F.FileName.LastIndexOf("\\"+ 1);
                    F.SaveAs(Path 
+ "/" + newName);
                }

            }


        }



posted @ 2006-11-13 12:02 dannyr|一个都不能少! 阅读(5258) | 评论 (10)编辑

http://www.json.org/


很简洁!比XML的DOM操作来的方便多了!直接可以作为javascript的对象来处理。比如用C#版的JSON,后台输出后,前台页面的js可以直接操作数据了!

.Net1.0的例子:http://dannyr.nbdown.net/JSON.zip
.Net2.0的例子: http://www.newtonsoft.com/products/json/
posted @ 2006-10-26 17:21 dannyr|一个都不能少! 阅读(2982) | 评论 (1)编辑
     摘要: 简介: Spry Framework是Adobe出品的轻量级的支持Ajax的JavaScript库,以HTML为中心,使用最基本的HTML、CSS和JavaScript来实现丰富Web页面体验。 本例子演示了数据集的字段排序功能以及对数据集排序时候触发的事件的处理;代码很简单,需要讲一下sort方法,sort方法有2个入口参数:字段名和排序顺序(ascending descending toggl... 阅读全文
posted @ 2006-10-26 15:52 dannyr|一个都不能少! 阅读(1972) | 评论 (2)编辑

简介

         Spry Framework是Adobe出品的轻量级的支持Ajax的JavaScript库,是一个包含JavaScript、CSS和图片文件的JavaScript库,必须在客户端浏览器中运行;支持XML数据集、动态区域显示、窗口显示部件和动态变换效果。
         用过Flex的朋友们可以很容易的看出这个Spry框架结构有点像Flex,并且使用HTTPService来与后台服务通讯。的确这个框架感觉每个层面的耦合很松弛,如下图所示,服务器端可以使用现有的主流技术,展示页面上可以通过DOM直接整合HTML等,是比较容易在现有的系统上改造及嵌入;同时Spry框架的设计目标是Web设计者,对于开发人员来说很容易上手和集成。


框架及浏览器结构:

fig01.gif

框架特点:
Spry框架是为Web设计设计者开发的,因此框架的每个元素都按以下原则设计:
   * 保持轻巧
   * 保持简单
          o使用标准的HTML、CSS和JavaScript技术
          o保持每个元素的所有属性/语法都绝对最小化
          o尽可能的简化脚本编程

posted @ 2006-10-20 10:05 dannyr|一个都不能少! 阅读(2256) | 评论 (7)编辑
简介
        Spry Framework是Adobe出品的轻量级的支持Ajax的JavaScript库,以HTML为中心,使用最基本的HTML、CSS和JavaScript来实现丰富Web页面体验。


试验环境

操作系统:windows2003 Server
浏览器:IE7.0 RC1      FireFox 1.5.0.7
WEB服务器:IIS 6.0
Spry库:Spry_P1_3_08-11


安装
http://labs.adobe.com/technologies/spry/ 下载安装包,目前版本为Spry_P1_3_08-11.zip,解开后把includes目录复制到自己的IIS虚拟目录上即可。


页面代码

test.html
 1<head>
 2    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 3    <title>Spry Example</title>
 4    
 5    <!--Link the Spry libraries-->
 6    <script type="text/javascript" src="includes/xpath.js"></script>
 7    <script type="text/javascript" src="includes/SpryData.js"></script>
 8    
 9    <!--Create a data set object-->
10    <script type="text/javascript">
11        var dsSpecials = new Spry.Data.XMLDataSet("data.xml""specials/menu_item");
12        var dsIngredients = new Spry.Data.XMLDataSet('{dsSpecials::url}', "item/ingredients/ingredient");
13    
</script>
14</head>
15
16<body>
17
18    <!--Create the Spry dynamic region-->
19    <div id="Specials_DIV" spry:region="dsSpecials">
20    <!--Display the data in a table-->
21        <table id="Specials_Table">
22        <tr>
23            <th>名称</th>
24            <th>Description</th>
25            <th>价格</th>
26        </tr>
27        <!--<tr spry:repeat="dsSpecials">-->