我需要一些帮助。我已经完成了对应用程序的编码,可以正常工作,但发布该应用程序时遇到了一些挑战。我已经设法将数据库复制到输出目录,但是,将imagess目录添加到输出目录对我来说已经成为一个很大的问题。图片目录包含可通过应用上传的自定义图片。我对.csproj做了一些更改,但没有成功。
.csproj
<Target Name="ContentsBeforeBuild" AfterTargets="BeforeBuild">
<ItemGroup>
<Content Include="images\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Target>
也使用
<Target Name="ContentsBeforeBuild" AfterTargets="BeforeBuild">
<ItemGroup>
<Content Include="images\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Target>
这是用于检索图像并将其显示到我的应用程序的代码。在发布应用程序之前,它运行良好,但是在发布之后,它返回目录未找到异常。
String paths = Application.StartupPath.Substring(0,(Application.StartupPath.Length - 10));
String imagePath = paths+"\\images\\"+col["itemPhoto"].ToString();
错误。发布
后无法访问图像目录我是否可以通过其他任何方式编写代码,以便从应用程序获取图像? 肯迪,我需要一些帮助。
一个星期内尝试发布我的应用程序..请帮助
.csproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">anycpu</Platform>
<ProjectGuid>{5765EB29-19B9-4FC8-8414-B033C956AE48}</ProjectGuid>
<OutputType>winexe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Shop_POS</RootNamespace>
<AssemblyName>Shop POS</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>C:\Users\dansyo\Desktop\pos\spos\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|anycpu' ">
<PlatformTarget>anycpu</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|anycpu' ">
<PlatformTarget>anycpu</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>logo1_15W_icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>986913D78C02BC6448BB7EBB687285F9D3AB2FD4</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>Shop POS_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<Signmanifests>true</Signmanifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Windows.Forms.DataVisualization" />
<Reference Include="system.xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="system.xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AddEmployeeDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AddEmployeeDialog.Designer.cs">
<DependentUpon>AddEmployeeDialog.cs</DependentUpon>
</Compile>
<Compile Include="AddItemDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AddItemDialog.Designer.cs">
<DependentUpon>AddItemDialog.cs</DependentUpon>
</Compile>
<Compile Include="ComboboxItem.cs" />
<Compile Include="BusinessProfile.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="BusinessProfile.Designer.cs">
<DependentUpon>BusinessProfile.cs</DependentUpon>
</Compile>
<Compile Include="DatabaseHandler.cs" />
<Compile Include="DeleteAlldata.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DeleteAlldata.Designer.cs">
<DependentUpon>DeleteAlldata.cs</DependentUpon>
</Compile>
<Compile Include="ForgottenPassword.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ForgottenPassword.Designer.cs">
<DependentUpon>ForgottenPassword.cs</DependentUpon>
</Compile>
<Compile Include="GenerateBarCode.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GenerateBarCode.Designer.cs">
<DependentUpon>GenerateBarCode.cs</DependentUpon>
</Compile>
<Compile Include="GenerateBarCodeDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GenerateBarCodeDialog.Designer.cs">
<DependentUpon>GenerateBarCodeDialog.cs</DependentUpon>
</Compile>
<Compile Include="OutOfStock.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OutOfStock.Designer.cs">
<DependentUpon>OutOfStock.cs</DependentUpon>
</Compile>
<Compile Include="Premiumactivation.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Premiumactivation.Designer.cs">
<DependentUpon>Premiumactivation.cs</DependentUpon>
</Compile>
<Compile Include="Recoveraccount.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Recoveraccount.Designer.cs">
<DependentUpon>Recoveraccount.cs</DependentUpon>
</Compile>
<Compile Include="Getter.cs" />
<Compile Include="Mainactivity.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Mainactivity.Designer.cs">
<DependentUpon>Mainactivity.cs</DependentUpon>
</Compile>
<Compile Include="Login.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Login.Designer.cs">
<DependentUpon>Login.cs</DependentUpon>
</Compile>
<Compile Include="Methods.cs" />
<Compile Include="PrintMyCart.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PrintMyCart.Designer.cs">
<DependentUpon>PrintMyCart.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Register.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Register.Designer.cs">
<DependentUpon>Register.cs</DependentUpon>
</Compile>
<Compile Include="ResetPassword.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ResetPassword.Designer.cs">
<DependentUpon>ResetPassword.cs</DependentUpon>
</Compile>
<Compile Include="RestoreDefault.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RestoreDefault.Designer.cs">
<DependentUpon>RestoreDefault.cs</DependentUpon>
</Compile>
<Compile Include="Selleractivity.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Selleractivity.Designer.cs">
<DependentUpon>Selleractivity.cs</DependentUpon>
</Compile>
<Compile Include="EmpMethod.cs" />
<Compile Include="SelleractivitySearchInventory.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SelleractivitySearchInventory.Designer.cs">
<DependentUpon>SelleractivitySearchInventory.cs</DependentUpon>
</Compile>
<Compile Include="Splash.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Splash.Designer.cs">
<DependentUpon>Splash.cs</DependentUpon>
</Compile>
<Compile Include="TaxDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TaxDialog.Designer.cs">
<DependentUpon>TaxDialog.cs</DependentUpon>
</Compile>
<Compile Include="TblCompanyProfile.cs" />
<Compile Include="TblInventory.cs" />
<Compile Include="TblRegister.cs" />
<Compile Include="TblSales.cs" />
<Compile Include="TblSellers.cs" />
<Compile Include="TblSettings.cs" />
<Compile Include="UpdateDelEmpDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UpdateDelEmpDialog.Designer.cs">
<DependentUpon>UpdateDelEmpDialog.cs</DependentUpon>
</Compile>
<Compile Include="UpdateDelInventoryDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UpdateDelInventoryDialog.Designer.cs">
<DependentUpon>UpdateDelInventoryDialog.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="AddEmployeeDialog.resx">
<DependentUpon>AddEmployeeDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="AddItemDialog.resx">
<DependentUpon>AddItemDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BusinessProfile.resx">
<DependentUpon>BusinessProfile.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="DeleteAlldata.resx">
<DependentUpon>DeleteAlldata.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ForgottenPassword.resx">
<DependentUpon>ForgottenPassword.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GenerateBarCode.resx">
<DependentUpon>GenerateBarCode.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GenerateBarCodeDialog.resx">
<DependentUpon>GenerateBarCodeDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="OutOfStock.resx">
<DependentUpon>OutOfStock.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Premiumactivation.resx">
<DependentUpon>Premiumactivation.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Recoveraccount.resx">
<DependentUpon>Recoveraccount.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Mainactivity.resx">
<DependentUpon>Mainactivity.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Login.resx">
<DependentUpon>Login.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PrintMyCart.resx">
<DependentUpon>PrintMyCart.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Register.resx">
<DependentUpon>Register.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ResetPassword.resx">
<DependentUpon>ResetPassword.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="RestoreDefault.resx">
<DependentUpon>RestoreDefault.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Selleractivity.resx">
<DependentUpon>Selleractivity.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SelleractivitySearchInventory.resx">
<DependentUpon>SelleractivitySearchInventory.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Splash.resx">
<DependentUpon>Splash.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="TaxDialog.resx">
<DependentUpon>TaxDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UpdateDelEmpDialog.resx">
<DependentUpon>UpdateDelEmpDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UpdateDelInventoryDialog.resx">
<DependentUpon>UpdateDelInventoryDialog.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Shop POS_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="images\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="logo\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="favicon.ico" />
<Content Include="images\alfa_romeo.jpg" />
<Content Include="logo1_15W_icon.ico" />
<Content Include="logo\DAEWOO.jpg" />
<Content Include="Properties\add.png" />
<None Include="Resources\za.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\microsoft.CSharp.targets" />
<!-- To modify your build process,add your task inside one of the targets below and uncomment it.
Other similar extension points exist,see microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>