如何用C替换文件中的字符

时间:2016-12-20 21:01:13

标签: c

我正在尝试在文本文件中找到特定字符的出现,然后将其替换为另一个。我尝试过像这样的东西。

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       creationComplete="windowedapplication1_creationCompleteHandler(event)">

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.FlexEvent;

            import spark.collections.Sort;
            import spark.collections.SortField;

            import utils.AlphaNumericSort;

            protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
            {
                var directory:File = File.desktopDirectory.resolvePath("testFolder");

                if (directory.exists){

                    var collection:ArrayCollection;     
                    var obj:*;
                    var sort:Sort;
                    var sortField:SortField;

                    collection = new ArrayCollection(directory.getDirectoryListing());
                    sort = new Sort();
                    sortField = new SortField("name");
                    sortField.compareFunction = AlphaNumericSort.compare;
                    sort.fields = [sortField];
                    collection.sort = sort;
                    collection.refresh();

                    trace("---------AlphaNumericSort")
                    for each (obj in collection){
                        trace(obj.name);
                    }
                    trace(" ");
                }
            }

        ]]>
    </fx:Script>
</s:WindowedApplication>

0 个答案:

没有答案