如何创建保存文件的应用程序

如何创建保存文件的应用程序

本文介绍了如何创建保存文件的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请给我一些残忍,我需要创建一个应该能够创建文件并在任何自定义文件扩展名中保存在任何存储介质上的应用程序。



例如,就像你使用Microsoft Office创建.doc文件一样,并且点击创建的文件,你可以加载ms office并加载文件内容。程序。



简而言之,我如何创建一个将数据存储在文件中的应用程序,只需单击创建的文件即可检索此数据。



我不想使用任何第三方应用程序,如sql,access等来存储数据。



我很擅长C#,但我只需要一些关于如何开始使用这种应用程序的想法。



提前付款



我尝试了什么:



我在想序列化可能是出路,但我不太确定如何实现单击创建的文件并加载应用程序文件数据

Hi every,
Please give me some cruel, i need to create an application which should be able to create a file and save on any storage media in any custom file extension.

For example, like how you create a .doc file with Microsoft office, and on clicking on the created file, you can be able to load ms office and load the file content in the program.

In brief, how can i create an app which stores data in a file and i can retrieve this data by just clicking on the created file.

I don't want to use any third party app like sql,access, etc to store data.

I am good in C#, but i just need some ideas on how to start off this kind of app.

Thanks in advance

What I have tried:

I am thinking serialization could be a way out,but am not very sure how to implement the clicking on the created file and load the app with the file data

推荐答案


Program.Main(string[] args)

方法,它也可用应用程序中的任何地方

method, it is also available anywhere in your app in

Environment.GetCommandLineArgs()

,(但要注意第一个元素将是你的应用程序的exe)



对于通过ClickOnce部署的应用程序,您需要访问:



, (although, beware the first element will be your app's exe)

For an application deployed through ClickOnce, you need to access:

AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData





对于WPF应用程序,您需要在App.xaml中处理启动事件:





For a WPF app, you need to handle the startup event in App.xaml:

<application x:class="XmlViewer.App" xmlns:x="#unknown">
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:XmlViewer"
             Startup="Application_Startup">
    <application.resources>

    </application.resources>
</application>







/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
    private void Application_Startup(object sender, StartupEventArgs e)
    {
        // process the command line argument
        if (System.IO.File.Exists(e.Args[0]))
        {
            // do stuff here
        }
    }
}


这篇关于如何创建保存文件的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 23:07